[FIX] purchase: vendor currency
When defined, the vendor currency should be the default on vendor bills. Fixes #13017 Closes #13016 opw-685016
This commit is contained in:
@@ -87,6 +87,22 @@ class AccountInvoice(models.Model):
|
||||
if purchase_ids:
|
||||
self.origin = ', '.join(purchase_ids.mapped('name'))
|
||||
|
||||
@api.onchange('partner_id', 'company_id')
|
||||
def _onchange_partner_id(self):
|
||||
res = super(AccountInvoice, self)._onchange_partner_id()
|
||||
if not self.env.context.get('default_journal_id') and self.partner_id and self.currency_id and\
|
||||
self.type in ['in_invoice', 'in_refund'] and\
|
||||
self.currency_id != self.partner_id.property_purchase_currency_id:
|
||||
journal_domain = [
|
||||
('type', '=', 'purchase'),
|
||||
('company_id', '=', self.company_id.id),
|
||||
('currency_id', '=', self.partner_id.property_purchase_currency_id.id),
|
||||
]
|
||||
default_journal_id = self.env['account.journal'].search(journal_domain, limit=1)
|
||||
if default_journal_id:
|
||||
self.journal_id = default_journal_id
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def invoice_line_move_line_get(self):
|
||||
res = super(AccountInvoice, self).invoice_line_move_line_get()
|
||||
|
||||
Reference in New Issue
Block a user