[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 052a5702c5.
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) <len@odoo.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user