From 0090a3c9243271dd22d8a106f8edb69f97431978 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Mon, 16 Dec 2019 10:58:27 +0000 Subject: [PATCH] [FIX] point_of_sale: avoid adding the same tax twice Activate a Fiscal position with a defined tax mapping(i.e. 15%). Add to a product the same tax. Set the tax to be included in price. In POS Settings add the default fiscal position as the one from before. Now open POS and add the product. The total price calculated will be wrong: the tax is added twice, one from the product line and one from the localization. Mimic the behavior as in https://github.com/odoo/odoo/blob/saas-12.3/addons/account/models/account.py#L1512 closes odoo/odoo#42194 X-original-commit: db16d119f02ed5244482276a3701d3d3ab2fdb7b Signed-off-by: Nicolas Lempereur (nle) --- addons/point_of_sale/static/src/js/models.js | 7 +++---- 1 file changed, 3 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 a81eb81d235..ed772c2d68b 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2629,7 +2629,7 @@ exports.Order = Backbone.Model.extend({ var mapped_included_taxes = []; _(taxes).each(function(tax) { var line_taxes = line._map_tax_fiscal_position(tax); - if(tax.price_include && _.contains(line_taxes, tax)){ + if(tax.price_include && !_.contains(line_taxes, tax)){ mapped_included_taxes.push(tax); } @@ -2655,6 +2655,7 @@ exports.Order = Backbone.Model.extend({ attr.pos = this.pos; attr.order = this; var line = new exports.Orderline({}, {pos: this.pos, order: this, product: product}); + this.fix_tax_included_price(line); if(options.quantity !== undefined){ line.set_quantity(options.quantity); @@ -2662,15 +2663,13 @@ exports.Order = Backbone.Model.extend({ if(options.price !== undefined){ line.set_unit_price(options.price); + this.fix_tax_included_price(line); } if(options.lst_price !== undefined){ line.set_lst_price(options.lst_price); } - //To substract from the unit price the included taxes mapped by the fiscal position - this.fix_tax_included_price(line); - if(options.discount !== undefined){ line.set_discount(options.discount); }