Skip to content
Permalink
Browse files

[FIX] purchase: onchange at create

When creating an invoice programmatically, make sure to retrieve the
`currency_id` field set by `_onchange_partner_id`.

opw-1951314
  • Loading branch information...
nim-odoo committed Mar 25, 2019
1 parent 1e9336a commit 576a15805c256c5d71e97573754be70274826940
Showing with 6 additions and 1 deletion.
  1. +6 −1 addons/purchase/models/account_invoice.py
@@ -131,7 +131,7 @@ def _onchange_partner_id(self):
res = super(AccountInvoice, self)._onchange_partner_id()
if payment_term_id:
self.payment_term_id = payment_term_id
if not self.env.context.get('default_journal_id') and self.partner_id and self.currency_id and\
if not self.env.context.get('default_journal_id') and self.partner_id and\
self.type in ['in_invoice', 'in_refund'] and\
self.currency_id != self.partner_id.property_purchase_currency_id and\
self.partner_id.property_purchase_currency_id.id:
@@ -172,6 +172,11 @@ def write(self, vals):
invoice.message_post(body=message)
return result

def _get_onchange_create(self):
res = super()._get_onchange_create()
res['_onchange_partner_id'].append('currency_id')
return res


class AccountInvoiceLine(models.Model):
""" Override AccountInvoice_line to add the link to the purchase order line it is related to"""

0 comments on commit 576a158

Please sign in to comment.
You can’t perform that action at this time.