Browse Source

Jul 12 : [UPDT] Updated 'pos_zero_quantity_restrict'

pull/266/head
AjmalCybro 2 years ago
parent
commit
df12aacb50
  1. 2
      pos_zero_quantity_restrict/__manifest__.py
  2. 2
      pos_zero_quantity_restrict/doc/RELEASE_NOTES.md
  3. 38
      pos_zero_quantity_restrict/static/src/js/Screens/PaymentScreen/ProductScreen.js

2
pos_zero_quantity_restrict/__manifest__.py

@ -31,13 +31,13 @@
'company': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com", 'website': "https://www.cybrosys.com",
'images': ['static/description/banner.jpg'],
'depends': ['base', 'point_of_sale'], 'depends': ['base', 'point_of_sale'],
'assets': { 'assets': {
'point_of_sale.assets': [ 'point_of_sale.assets': [
'pos_zero_quantity_restrict/static/src/js/**/*.js', 'pos_zero_quantity_restrict/static/src/js/**/*.js',
] ]
}, },
'images': ['static/description/banner.jpg'],
'license': 'AGPL-3', 'license': 'AGPL-3',
'installable': True, 'installable': True,
'auto_install': False, 'auto_install': False,

2
pos_zero_quantity_restrict/doc/RELEASE_NOTES.md

@ -3,4 +3,4 @@
#### 20.06.2023 #### 20.06.2023
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD
Initial Commit for POS Restriction For Zero Quantity. - Initial Commit for POS Restriction For Zero Quantity.

38
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'); const { Gui } = require('point_of_sale.Gui');
export const PosZeroQuantityRestrictProductScreen = (ProductScreen) => export const PosZeroQuantityRestrictProductScreen = (ProductScreen) =>
class extends ProductScreen { class extends ProductScreen {
//@override //@override
async _onClickPay() { async _onClickPay() {
for (var i = 0; i < this.env.pos.get_order().orderlines.length; i++) { const orderLines = this.env.pos.get_order().orderlines;
// get orderline quantity for (let i = 0; i < orderLines.length; i++) {
var qty = this.env.pos.get_order().orderlines[this.env.pos.get_order().orderlines.length - 1].quantity const qty = orderLines[i].quantity;
if (qty !== 0){ if (qty === 0) {
await super._onClickPay(...arguments); // Do not confirm the order and show error popup
}else { Gui.showPopup('ErrorPopup', {
// do not confirm the order and show error popup; title: 'Zero quantity not allowed',
Gui.showPopup('ErrorPopup', { body: 'Only a positive quantity is allowed for confirming the order',
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); // If all order lines have a positive quantity, call the original _onClickPay method
await super._onClickPay(...arguments);
}
};
Registries.Component.extend(ProductScreen, PosZeroQuantityRestrictProductScreen);

Loading…
Cancel
Save