From ea1fc124efca316d2a5a0ad9d93ebd75f71c9eb6 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Mon, 8 Apr 2019 13:18:26 +0000 Subject: [PATCH] [FIX] purchase: update reference onchange of vendor_bill_purchase_id Commit 1be873d4 removed the modification of the reference field from the _onchange_origin. The reasoning was that since this is an onchange on invoice_line_ids, it was applied too often, which annoyed users in the case they overwrote that field. However when using the "Autocomplete" field (vendor_bill_purchase_id), then the user expects values to by modified. Before, it worked by setting the origin field, which trickled down to the reference. Since that commit removed this, we re-add it explicitly in that case. opw 1962364 closes odoo/odoo#32500 Signed-off-by: Nans Lefebvre (len) --- addons/purchase/models/account_invoice.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 9f63039afd7..6c7b1b9293d 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -25,6 +25,10 @@ class AccountInvoice(models.Model): 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 {}