[FIX] account,sale: Select correclty the delivery partner

To deduct the fiscal position, we should use the shipping partner.

The field `partner_shipping_id` is defined in the sale module.

Thus, we should choose this partner if the module sale is installed and if this field is set, or fallback to the original partner instead
This commit is contained in:
Yannick Tivisse
2017-04-07 16:17:49 +02:00
parent cf81b665e5
commit a3778ceada
2 changed files with 9 additions and 1 deletions
+5 -1
View File
@@ -484,7 +484,7 @@ class AccountInvoice(models.Model):
account_id = pay_account.id
payment_term_id = p.property_supplier_payment_term_id.id
delivery_partner_id = self.partner_shipping_id.id or self.partner_id.address_get(['delivery'])['delivery']
delivery_partner_id = self.get_delivery_partner_id()
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
@@ -513,6 +513,10 @@ class AccountInvoice(models.Model):
return {'domain': {'partner_bank_id': [('id', 'in', bank_ids.ids)]}}
return {}
@api.multi
def get_delivery_partner_id(self):
self.ensure_one()
return self.partner_id.address_get(['delivery'])['delivery']
@api.onchange('journal_id')
def _onchange_journal_id(self):
+4
View File
@@ -84,6 +84,10 @@ class AccountInvoice(models.Model):
return report_pages
@api.multi
def get_delivery_partner_id(self):
self.ensure_one()
return self.partner_shipping_id.id or super(AccountInvoice, self).get_delivery_partner_id()
class AccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'