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',
'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,

2
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.
- 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');
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);
}
// 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