From 8a287c723389d1c85b619ed0d4c5c9198dbb96c8 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Wed, 9 Jun 2021 10:02:01 +0000 Subject: [PATCH] [FIX] point_of_sale: correct compute prices of order in OrderManagementScreen When viewing an order in the order management screen that has customer with fiscal position, the calculation of prices is based on the fiscal position of the currently active order. This commit fixes the issue by properly specifying the order in the calculation of taxes based on the order's customer and/or fiscal position. closes odoo/odoo#73396 X-original-commit: 889ab379e2e7533a4506be0e8d2badfe4c5c7f90 Related: odoo/enterprise#19509 Signed-off-by: pimodoo --- addons/point_of_sale/static/src/js/models.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index b5a9b92fc19..d930898ae6e 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2052,9 +2052,9 @@ exports.Orderline = Backbone.Model.extend({ } return taxes; }, - _map_tax_fiscal_position: function(tax) { + _map_tax_fiscal_position: function(tax, order = false) { var self = this; - var current_order = this.pos.get_order(); + var current_order = order || this.pos.get_order(); var order_fiscal_position = current_order && current_order.fiscal_position; var taxes = []; @@ -2266,7 +2266,7 @@ exports.Orderline = Backbone.Model.extend({ var tax = _.detect(taxes, function(t){ return t.id === el; }); - product_taxes.push.apply(product_taxes, self._map_tax_fiscal_position(tax)); + product_taxes.push.apply(product_taxes, self._map_tax_fiscal_position(tax, self.order)); }); product_taxes = _.uniq(product_taxes, function(tax) { return tax.id; }); @@ -2297,7 +2297,7 @@ exports.Orderline = Backbone.Model.extend({ var new_included_taxes = []; var self = this; _(taxes).each(function(tax) { - var line_taxes = self._map_tax_fiscal_position(tax); + var line_taxes = self._map_tax_fiscal_position(tax, order); if (line_taxes.length && line_taxes[0].price_include){ new_included_taxes = new_included_taxes.concat(line_taxes); }