Skip to content
Permalink
Browse files

[FIX] purchase: move reference update to the right onchange

Move the code from commit ea1fc12 to the onchange on purchase_id.
The field vendor_bill_purchase_id is a technical one added in v12 to allow using
old vendor bills as template for new vendor bills.
However the logic on purchase_id was already in v11, so we match commit 1423973

opw 1962364

closes #32661

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
  • Loading branch information...
len-odoo committed Apr 11, 2019
1 parent 9172139 commit 30b5e0c024254049c68125b4c920ec1b202aa328
Showing with 5 additions and 4 deletions.
  1. +5 −4 addons/purchase/models/account_invoice.py
@@ -25,10 +25,6 @@ def _onchange_bill_purchase_order(self):
return {}
self.purchase_id = self.vendor_bill_purchase_id.purchase_order_id
self.vendor_bill_id = self.vendor_bill_purchase_id.vendor_bill_id
vendor_ref = self.vendor_bill_purchase_id.purchase_order_id.partner_ref
if vendor_ref:
self.reference = ", ".join([self.reference, vendor_ref]) if (
self.reference and vendor_ref not in self.reference) else vendor_ref
self.vendor_bill_purchase_id = False
return {}

@@ -98,6 +94,11 @@ def purchase_order_change(self):
if not self.partner_id:
self.partner_id = self.purchase_id.partner_id.id

vendor_ref = self.purchase_id.partner_ref
if vendor_ref:
self.reference = ", ".join([self.reference, vendor_ref]) if (
self.reference and vendor_ref not in self.reference) else vendor_ref

if not self.invoice_line_ids:
#as there's no invoice line yet, we keep the currency of the PO
self.currency_id = self.purchase_id.currency_id

0 comments on commit 30b5e0c

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