From 2749f73f9b5f0c26595fd09fc4e7613b9201c05e Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 2 Dec 2015 14:47:33 +0100 Subject: [PATCH] [FIX] sale: update_tax in product_id_change Thanks to the fix 503820a, when a fiscal position mapped an included tax on a SO line, the price unit of the product is recomputed. This fix has been applied in the function product_id_change in the model "sale.order.line" Before the fix, when changing the product uom on a SO line, the price unit of the SO line was reset with the pricelist price without taking into account the fact that a included tax could be removed on the SO line. To avoid this kind of problem, the price unit must be recomputed in any case according to the taxes. --- addons/sale/sale.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 66c53b683e7..053afb198af 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1142,15 +1142,12 @@ class sale_order_line(osv.osv): fpos = partner.property_account_position or False else: fpos = self.pool.get('account.fiscal.position').browse(cr, uid, fiscal_position) - if update_tax: #The quantity only have changed - # The superuser is used by website_sale in order to create a sale order. We need to make - # sure we only select the taxes related to the company of the partner. This should only - # apply if the partner is linked to a company. - if uid == SUPERUSER_ID and context.get('company_id'): - taxes = product_obj.taxes_id.filtered(lambda r: r.company_id.id == context['company_id']) - else: - taxes = product_obj.taxes_id - result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) + + if uid == SUPERUSER_ID and context.get('company_id'): + taxes = product_obj.taxes_id.filtered(lambda r: r.company_id.id == context['company_id']) + else: + taxes = product_obj.taxes_id + result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) if not flag: result['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1] @@ -1209,8 +1206,7 @@ class sale_order_line(osv.osv): warning_msgs += _("No valid pricelist line found ! :") + warn_msg +"\n\n" else: - if update_tax: - price = self.pool['account.tax']._fix_tax_included_price(cr, uid, price, taxes, result['tax_id']) + price = self.pool['account.tax']._fix_tax_included_price(cr, uid, price, taxes, result['tax_id']) result.update({'price_unit': price}) if context.get('uom_qty_change', False): values = {'price_unit': price}