[FIX] wesbite_sale: recompute taxes when fiscal position is updated

We force to recompute the taxes on all lines when we change the fiscal position.
That was already done in backend, with the onchange.
But @api.contrains allow to do it on each write on fiscal_position_id field.

@api.Depends will not work because it is not a computed field.
This commit is contained in:
Jeremy Kersten
2015-12-11 10:09:52 +01:00
parent 7e2628aeb2
commit 0f25a8ce1d
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -85,6 +85,7 @@ class SaleOrder(models.Model):
default_team_id = self.env['crm.team']._get_default_team_id()
return self.env['crm.team'].browse(default_team_id)
@api.constrains('fiscal_position_id')
@api.onchange('fiscal_position_id')
def _compute_tax_id(self):
"""
+2 -2
View File
@@ -625,7 +625,6 @@ class website_sale(http.Controller):
partner_id = orm_partner.create(cr, SUPERUSER_ID, billing_info, context=context)
order.write({'partner_id': partner_id, 'partner_invoice_id': partner_id})
order_obj.onchange_partner_id(cr, SUPERUSER_ID, [order.id], context=context)
order_obj.onchange_partner_shipping_id(cr, SUPERUSER_ID, [order.id], context=context)
# create a new shipping partner
if checkout.get('shipping_id') == -1:
@@ -635,7 +634,8 @@ class website_sale(http.Controller):
shipping_info['parent_id'] = partner_id
checkout['shipping_id'] = orm_partner.create(cr, SUPERUSER_ID, shipping_info, context)
order.write({'partner_shipping_id': checkout.get('shipping_id')})
order_obj.onchange_partner_shipping_id(cr, SUPERUSER_ID, [order.id], context=context)
order_obj.onchange_partner_shipping_id(cr, SUPERUSER_ID, [order.id], context=context)
order_info = {
'message_partner_ids': [(4, partner_id), (3, request.website.partner_id.id)],