From a3d6e7f2ff216e2b3672fa1579d331801f9d5c0e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 24 Oct 2016 11:05:08 +0200 Subject: [PATCH 1/2] [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 --- addons/sale/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 29b12b5f111..661880cfd98 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -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. From 4d1fc7e390eea67a4db2a259b05b3779872ba034 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 24 Oct 2016 11:17:45 +0200 Subject: [PATCH 2/2] [FIX] sale: missing account mapping in advance invoice The `map_account()` method expects a browse_record as parameter, and returns a browse_record (possibly the argument if no mapping happened). It was being called with an account ID instead, so fiscal position mapping would never match, and would always return the argument itself. --- addons/sale/wizard/sale_make_invoice_advance.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index a543f598148..925877b75e7 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -65,9 +65,8 @@ class SaleAdvancePaymentInv(models.TransientModel): if self.product_id.id: account_id = self.product_id.property_account_income_id.id if not account_id: - prop = ir_property_obj.get('property_account_income_categ_id', 'product.category') - prop_id = prop and prop.id or False - account_id = order.fiscal_position_id.map_account(prop_id) + inc_acc = ir_property_obj.get('property_account_income_categ_id', 'product.category') + account_id = order.fiscal_position_id.map_account(inc_acc).id if inc_acc else False if not account_id: raise UserError( _('There is no income account defined for this product: "%s". You may have to install a chart of account from Accounting app, settings menu.') % \