From ce6df4145a99b2e99a39c7b0062cf04d105a73a9 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Thu, 2 Dec 2021 10:45:41 +0000 Subject: [PATCH] [FIX] l10n_fr_pos_cert: should prevent order from being deleted A bug was introduced in FR localization after the implementation of refund feature in point_of_sale module, that is, any order can now be deleted. However, we don't want this in the localization. This fix restores the error message that prevents the deletion of of any order made under the FR localization. However, this time, instead of only preventing the current order to be deleted, we keep every order with orderlines from being deleted. closes odoo/odoo#80773 X-original-commit: 30b48094fb59f564b923e34a3df379f8ff0610de Signed-off-by: Masereel Pierre --- addons/l10n_fr_pos_cert/static/src/js/pos.js | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) 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 86dc047ed14..1c131bd0e88 100644 --- a/addons/l10n_fr_pos_cert/static/src/js/pos.js +++ b/addons/l10n_fr_pos_cert/static/src/js/pos.js @@ -24,17 +24,6 @@ models.PosModel = models.PosModel.extend({ } return _.contains(french_countries, this.company.country.code); }, - delete_current_order: function () { - if (this.is_french_country() && this.get_order().get_orderlines().length) { - Gui.showPopup("ErrorPopup", { - 'title': _t("Fiscal Data Module error"), - 'body': _t("Deleting of orders is not allowed."), - }); - } else { - _super_posmodel.delete_current_order.apply(this, arguments); - } - }, - disallowLineQuantityChange() { let result = _super_posmodel.disallowLineQuantityChange.bind(this)(); return this.is_french_country() || result; @@ -64,7 +53,19 @@ models.Order = models.Order.extend({ var result = _super_order.wait_for_push_order.apply(this,arguments); result = Boolean(result || this.pos.is_french_country()); return result; - } + }, + destroy: function(reason) { + // SUGGESTION: It's probably more appropriate to apply this restriction + // in the TicketScreen. + if (this.pos.is_french_country() && this.get_orderlines().length) { + Gui.showPopup("ErrorPopup", { + 'title': _t("Fiscal Data Module error"), + 'body': _t("Deleting of orders is not allowed."), + }); + } else { + _super_order.destroy.apply(this, arguments); + } + }, }); var orderline_super = models.Orderline.prototype;