From 1be873d40d7aa8b1959e3c5a1ec6a6ead2323b6a Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Mon, 11 Mar 2019 09:06:30 +0000 Subject: [PATCH] [FIX] purchase: do not overwrite vendor reference on vendor bills The reference fields is supposed to contain the reference number in the vendor's system. E.g. if the vendor is using Odoo, it could be SO0744. Therefore this reference is not supposed to change once written by the user. However there is the _onchange_origin that uses the origin purchase order lines to populate the reference fields on invoice_line_ids changes. We remove entirely this behaviour for reference, essentially reverting 052a5702c500. Instead we put a default for origin and reference in action_view_invoice so that these values are initially used at create. opw 1920747 opw 1944840 closes odoo/odoo#31757 Signed-off-by: Nans Lefebvre (len) --- addons/purchase/models/account_invoice.py | 1 - addons/purchase/models/purchase.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 1490bb9fec9..e7e801429d1 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -103,7 +103,6 @@ class AccountInvoice(models.Model): purchase_ids = self.invoice_line_ids.mapped('purchase_id') if purchase_ids: self.origin = ', '.join(purchase_ids.mapped('name')) - self.reference = ', '.join(purchase_ids.filtered('partner_ref').mapped('partner_ref')) or self.reference @api.onchange('partner_id', 'company_id') def _onchange_partner_id(self): diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 7f746436258..8142090ddbc 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -532,6 +532,8 @@ class PurchaseOrder(models.Model): res = self.env.ref('account.invoice_supplier_form', False) result['views'] = [(res and res.id or False, 'form')] result['res_id'] = self.invoice_ids.id + result['context']['default_origin'] = self.name + result['context']['default_reference'] = self.partner_ref return result @api.multi