[FIX] purchase: change invoice date

- Create a PO, generate the vendor bill
- Change a price unit
- Change the invoice date

The price unit is reset to the PO value.

We only recompute it if the currency of the invoice is different from
the currency of the PO.

Fixes #22164
opw-804894
This commit is contained in:
Nicolas Martinelli
2018-01-15 08:47:05 +01:00
committed by Nicolas Martinelli
parent aa875b08af
commit d8112b0238
+3 -1
View File
@@ -89,7 +89,9 @@ class AccountInvoice(models.Model):
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.with_context(date=self.date_invoice).compute(line.purchase_line_id.price_unit, self.currency_id, round=False)
if line.purchase_id.currency_id != self.currency_id:
line.price_unit = line.purchase_id.currency_id.with_context(date=self.date_invoice)\
.compute(line.purchase_line_id.price_unit, self.currency_id, round=False)
@api.onchange('invoice_line_ids')
def _onchange_origin(self):