diff options
| author | Robin Heinz <rhe@odoo.com> | 2020-04-02 11:20:10 +0000 |
|---|---|---|
| committer | Pierre Masereel <pim@odoo.com> | 2020-05-12 12:52:23 +0000 |
| commit | 0e2aeb10af8b48312e1335865298e636cd29c1e2 (patch) | |
| tree | 6bac007b83b99f708669de64f98ce1589ef5bb71 /addons/l10n_fr_pos_cert | |
| parent | 85c11d1d40b5b54527fae5856c5884f4ad48fe7a (diff) | |
[IMP] point_of_sale,l10n_fr_pos_cert,pos_restaurant: new set quantity
For most localizations, decreasing quantity of an orderline is
prohibited. This commit generalizes this behavior and is now available
in core point_of_sale.
Diffstat (limited to 'addons/l10n_fr_pos_cert')
4 files changed, 12 insertions, 28 deletions
diff --git a/addons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js b/addons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js index 5362db2daff..ad6f0948850 100644 --- a/addons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js +++ b/addons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js @@ -5,15 +5,11 @@ odoo.define('l10n_fr_pos_cert.NumpadWidget', function(require) { const Registries = require('point_of_sale.Registries'); const PosFrNumpadWidget = NumpadWidget => class extends NumpadWidget { - async changeMode(mode) { - if (this.env.pos.is_french_country() && mode === 'price') { - await this.showPopup('ErrorPopup', { - title: this.env._t('Module error'), - body: this.env._t('Adjusting the price is not allowed.'), - }); - return; + get hasPriceControlRights() { + if (this.env.pos.is_french_country()) { + return false; } else { - super.changeMode(mode); + return super.hasPriceControlRights; } } }; diff --git a/addons/l10n_fr_pos_cert/static/src/js/ProductScreen.js b/addons/l10n_fr_pos_cert/static/src/js/ProductScreen.js deleted file mode 100644 index 97b781e4130..00000000000 --- a/addons/l10n_fr_pos_cert/static/src/js/ProductScreen.js +++ /dev/null @@ -1,16 +0,0 @@ -odoo.define('l10n_fr_pos_cert.ProductScreen', function(require) { - - const ProductScreen = require('point_of_sale.ProductScreen'); - const Registries = require('point_of_sale.Registries'); - - const PosFrProductScreen = ProductScreen => class extends ProductScreen { - disallowLineQuantityChange() { - let result = super.disallowLineQuantityChange(); - return (this.env.pos.is_french_country() && this.numpadMode === 'quantity') || result; - } - }; - - Registries.Component.extend(ProductScreen, PosFrProductScreen); - - return ProductScreen; -}); diff --git a/addons/l10n_fr_pos_cert/static/src/js/pos.js b/addons/l10n_fr_pos_cert/static/src/js/pos.js index 8ab462d8ed4..a02b50ea906 100644 --- a/addons/l10n_fr_pos_cert/static/src/js/pos.js +++ b/addons/l10n_fr_pos_cert/static/src/js/pos.js @@ -34,6 +34,11 @@ models.PosModel = models.PosModel.extend({ _super_posmodel.delete_current_order.apply(this, arguments); } }, + + disallowLineQuantityChange() { + let result = _super_posmodel.disallowLineQuantityChange(); + return this.is_french_country() || result; + } }); @@ -65,10 +70,10 @@ models.Order = models.Order.extend({ var orderline_super = models.Orderline.prototype; models.Orderline = models.Orderline.extend({ can_be_merged_with: function(orderline) { - var order = this.pos.get_order(); - var last_id = Object.keys(order.orderlines._byId)[Object.keys(order.orderlines._byId).length-1]; + let order = this.pos.get_order(); + let lastId = order.orderlines.last().cid; - if(this.pos.is_french_country() && (order.orderlines._byId[last_id].product.id !== orderline.product.id || order.orderlines._byId[last_id].quantity < 0)) { + if(this.pos.is_french_country() && (order.orderlines._byId[lastId].product.id !== orderline.product.id || order.orderlines._byId[lastId].quantity < 0)) { return false; } else { return orderline_super.can_be_merged_with.apply(this, arguments); diff --git a/addons/l10n_fr_pos_cert/views/l10n_fr_pos_cert_templates.xml b/addons/l10n_fr_pos_cert/views/l10n_fr_pos_cert_templates.xml index af683547c17..739d9dc93ec 100644 --- a/addons/l10n_fr_pos_cert/views/l10n_fr_pos_cert_templates.xml +++ b/addons/l10n_fr_pos_cert/views/l10n_fr_pos_cert_templates.xml @@ -6,7 +6,6 @@ <script type="text/javascript" src="/l10n_fr_pos_cert/static/src/js/pos.js"></script> <script type="text/javascript" src="/l10n_fr_pos_cert/static/src/js/NumpadWidget.js"></script> <script type="text/javascript" src="/l10n_fr_pos_cert/static/src/js/PaymentScreen.js"></script> - <script type="text/javascript" src="/l10n_fr_pos_cert/static/src/js/ProductScreen.js"></script> </xpath> </template> |
