From 1452a9903cf47b39d7fdb9bb788e99550ee943d2 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Thu, 6 Apr 2017 17:49:03 +0200 Subject: [PATCH] [FIX] account: Use the invoice shipping address to select the fiscal position Tribute to Ray Carnes PURPOSE ======= Since the fields shipping_partner_id has been added on the invoice model, the onchange triggered by the partner_id hasn't been modified. SPECIFICATION ============= The shipping_partner_id will be picked by default to select the fiscal position. If there's no shipping partner, it will check if a 'shipping' partner is a child on the partner_id. --- addons/account/models/account_invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index c24bdb5cf4f..6c97617b659 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -483,9 +483,9 @@ class AccountInvoice(models.Model): else: account_id = pay_account.id payment_term_id = p.property_supplier_payment_term_id.id - addr = self.partner_id.address_get(['delivery']) - fiscal_position = self.env['account.fiscal.position'].get_fiscal_position(self.partner_id.id, delivery_id=addr['delivery']) + delivery_partner_id = self.partner_shipping_id.id or self.partner_id.address_get(['delivery'])['delivery'] + fiscal_position = self.env['account.fiscal.position'].get_fiscal_position(self.partner_id.id, delivery_id=delivery_partner_id) # If partner has no warning, check its company if p.invoice_warn == 'no-message' and p.parent_id: