[FIX] purchase: convert to invoice currency
When a PO is imported, convert the prices in the currency of the invoice. Moreover, an onchange on the currency will recalculate the prices if necessary. opw-656762
This commit is contained in:
@@ -74,7 +74,7 @@ class AccountInvoice(models.Model):
|
||||
'uom_id': line.product_uom.id,
|
||||
'product_id': line.product_id.id,
|
||||
'account_id': self.env['account.invoice.line'].with_context({'journal_id': self.journal_id.id, 'type': 'in_invoice'})._default_account(),
|
||||
'price_unit': line.price_unit,
|
||||
'price_unit': line.order_id.currency_id.compute(line.price_unit, self.currency_id),
|
||||
'quantity': qty,
|
||||
'discount': 0.0,
|
||||
'account_analytic_id': line.account_analytic_id.id,
|
||||
@@ -90,6 +90,12 @@ class AccountInvoice(models.Model):
|
||||
self.purchase_id = False
|
||||
return {}
|
||||
|
||||
@api.onchange('currency_id')
|
||||
def _onchange_currency_id(self):
|
||||
if self.currency_id:
|
||||
for line in self.invoice_line_ids.filtered(lambda r: r.purchase_line_id):
|
||||
line.price_unit = line.purchase_id.currency_id.compute(line.purchase_line_id.price_unit, self.currency_id)
|
||||
|
||||
@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