[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.
This commit is contained in:
parent
d9f92ba160
commit
2749f73f9b
|
@ -1142,15 +1142,12 @@ class sale_order_line(osv.osv):
|
||||||
fpos = partner.property_account_position or False
|
fpos = partner.property_account_position or False
|
||||||
else:
|
else:
|
||||||
fpos = self.pool.get('account.fiscal.position').browse(cr, uid, fiscal_position)
|
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
|
if uid == SUPERUSER_ID and context.get('company_id'):
|
||||||
# sure we only select the taxes related to the company of the partner. This should only
|
taxes = product_obj.taxes_id.filtered(lambda r: r.company_id.id == context['company_id'])
|
||||||
# apply if the partner is linked to a company.
|
else:
|
||||||
if uid == SUPERUSER_ID and context.get('company_id'):
|
taxes = product_obj.taxes_id
|
||||||
taxes = product_obj.taxes_id.filtered(lambda r: r.company_id.id == context['company_id'])
|
result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
|
||||||
else:
|
|
||||||
taxes = product_obj.taxes_id
|
|
||||||
result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
|
|
||||||
|
|
||||||
if not flag:
|
if not flag:
|
||||||
result['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1]
|
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"
|
warning_msgs += _("No valid pricelist line found ! :") + warn_msg +"\n\n"
|
||||||
else:
|
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})
|
result.update({'price_unit': price})
|
||||||
if context.get('uom_qty_change', False):
|
if context.get('uom_qty_change', False):
|
||||||
values = {'price_unit': price}
|
values = {'price_unit': price}
|
||||||
|
|
Loading…
Reference in New Issue