From df12aacb50dc1b9825b8eb860b59b225b2a4c9df Mon Sep 17 00:00:00 2001 From: AjmalCybro Date: Wed, 12 Jul 2023 12:00:16 +0530 Subject: [PATCH] Jul 12 : [UPDT] Updated 'pos_zero_quantity_restrict' --- pos_zero_quantity_restrict/__manifest__.py | 2 +- .../doc/RELEASE_NOTES.md | 2 +- .../js/Screens/PaymentScreen/ProductScreen.js | 38 ++++++++++--------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/pos_zero_quantity_restrict/__manifest__.py b/pos_zero_quantity_restrict/__manifest__.py index 48c52392c..01ecc1772 100644 --- a/pos_zero_quantity_restrict/__manifest__.py +++ b/pos_zero_quantity_restrict/__manifest__.py @@ -31,13 +31,13 @@ 'company': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions', 'website': "https://www.cybrosys.com", + 'images': ['static/description/banner.jpg'], 'depends': ['base', 'point_of_sale'], 'assets': { 'point_of_sale.assets': [ 'pos_zero_quantity_restrict/static/src/js/**/*.js', ] }, - 'images': ['static/description/banner.jpg'], 'license': 'AGPL-3', 'installable': True, 'auto_install': False, diff --git a/pos_zero_quantity_restrict/doc/RELEASE_NOTES.md b/pos_zero_quantity_restrict/doc/RELEASE_NOTES.md index 529ad1e19..70bb7a2cf 100644 --- a/pos_zero_quantity_restrict/doc/RELEASE_NOTES.md +++ b/pos_zero_quantity_restrict/doc/RELEASE_NOTES.md @@ -3,4 +3,4 @@ #### 20.06.2023 #### Version 16.0.1.0.0 #### ADD -Initial Commit for POS Restriction For Zero Quantity. \ No newline at end of file + - Initial Commit for POS Restriction For Zero Quantity. \ No newline at end of file diff --git a/pos_zero_quantity_restrict/static/src/js/Screens/PaymentScreen/ProductScreen.js b/pos_zero_quantity_restrict/static/src/js/Screens/PaymentScreen/ProductScreen.js index 9112d8896..512a70810 100644 --- a/pos_zero_quantity_restrict/static/src/js/Screens/PaymentScreen/ProductScreen.js +++ b/pos_zero_quantity_restrict/static/src/js/Screens/PaymentScreen/ProductScreen.js @@ -4,22 +4,24 @@ const Registries = require('point_of_sale.Registries'); const { Gui } = require('point_of_sale.Gui'); export const PosZeroQuantityRestrictProductScreen = (ProductScreen) => - class extends ProductScreen { - //@override - async _onClickPay() { - for (var i = 0; i < this.env.pos.get_order().orderlines.length; i++) { - // get orderline quantity - var qty = this.env.pos.get_order().orderlines[this.env.pos.get_order().orderlines.length - 1].quantity - if (qty !== 0){ - await super._onClickPay(...arguments); - }else { - // do not confirm the order and show error popup; - Gui.showPopup('ErrorPopup', { - title: ('Zero quantity not allowed'), - body: ('Only a positive quantity is allowed for confirming the order') - }); - } - } + class extends ProductScreen { + //@override + async _onClickPay() { + const orderLines = this.env.pos.get_order().orderlines; + for (let i = 0; i < orderLines.length; i++) { + const qty = orderLines[i].quantity; + if (qty === 0) { + // Do not confirm the order and show error popup + Gui.showPopup('ErrorPopup', { + title: 'Zero quantity not allowed', + body: 'Only a positive quantity is allowed for confirming the order', + }); + return; // Exit the loop and do not proceed with confirming the order } - }; -Registries.Component.extend(ProductScreen, PosZeroQuantityRestrictProductScreen); \ No newline at end of file + } + // If all order lines have a positive quantity, call the original _onClickPay method + await super._onClickPay(...arguments); + } + }; + +Registries.Component.extend(ProductScreen, PosZeroQuantityRestrictProductScreen);