[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:
@@ -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):
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user