[FIX] sale: fix recompute of fiscal position

The `fiscal_position_id` field actually depends on both
the `shipping_partner_id` and the `partner_id` field,
not just the former.

Theoretically the recompute should trigger on both fields
anyway because changing the `partner_id` will automatically
change the `shipping_partner_id`.

Unfortunately this onchange chaining does not work as expected
as of Odoo 9, at least when the `partner_id` field is set
to the same value (was done for optimization reasons).
This special case really happens when you edit the Partner
from a sales order form view, and save the changes.
It triggers a "dummy on_change" for the `partner_id`
value, with the same value as before.
If the edit changed the fiscal position or another
field on which it depends, a recompute is really needed.

Adding the direct dependency works around this limitation,
and is semantically valid, too.

An extra fix of this special case in the framework might still
be nice to have, though.

Ref: feedback ID 29042
This commit is contained in:
Olivier Dony
2016-10-24 13:58:29 +02:00
parent 6690bfb14a
commit a3d6e7f2ff
+1 -1
View File
@@ -173,7 +173,7 @@ class SaleOrder(models.Model):
return super(SaleOrder, self)._track_subtype(init_values)
@api.multi
@api.onchange('partner_shipping_id')
@api.onchange('partner_shipping_id', 'partner_id')
def onchange_partner_shipping_id(self):
"""
Trigger the change of fiscal position when the shipping address is modified.