[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) <nle@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2019-12-19 15:27:32 +00:00
parent 141b34f152
commit 0090a3c924
+3 -4
View File
@@ -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);
}