From 1cfac2f2cd69c28ce2beeb352cf1422e1b696d6f Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Thu, 7 Apr 2022 10:03:06 +0000 Subject: [PATCH] [FIX] point_of_sale: ui stuck when product has grouped tax To reproduce: 1. Create a grouped tax with multiple taxes. Reorder the tax items. (Important step.) 2. Assign tax to the product. 3. Open pos loading the product. 4. a. [BUG] If pos config is tax-included -> non-responsive ui. 4. b. [BUG] If pos config is tax-excluded: Add the product. -> non-responsive ui. Fix: With the new reactivity in owl, mutating reactive objects will trigger rerender. However, computing tax amount of orderline or product with grouped taxes result to mutation of a reactive object, triggering an infinite render (render -> compute with mutation -> will trigger another render -> ...). The call to sort is mutating the reactive array referred by `children_tax_ids`. To prevent this infinite render, the solution is to use a copy of the array when sorting the taxes. OPW-2816546 closes odoo/odoo#88245 X-original-commit: b273056a12a34fec75d980e8a4a08ebaedad7e9c Signed-off-by: Masereel Pierre Signed-off-by: Joseph Caburnay (jcb) --- addons/point_of_sale/static/src/js/models.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 46376b41676..218992d845b 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1718,7 +1718,7 @@ class Orderline extends PosModel { // 1) Flatten the taxes. var _collect_taxes = function(taxes, all_taxes){ - taxes.sort(function (tax1, tax2) { + taxes = [...taxes].sort(function (tax1, tax2) { return tax1.sequence - tax2.sequence; }); _(taxes).each(function(tax){