Skip to content
Snippets Groups Projects
Commit ff4f3922 authored by Nans Lefebvre's avatar Nans Lefebvre
Browse files

[FIX] purchase: fix reference update at onchange


Add two PO with references 'XY' and 'Z' to a vendor bill.
The reference is computed as 'XY, Z' (with ', ' as separator).
Add a PO with reference 'X', the reference becomes 'X' instead of 'XY, Z, X'.

There are two variables that may not be defined (vendor_ref and self.reference),
and specifically the case where a reference is the prefix of another one is not
correctly dealt with.

opw 2005825

closes odoo/odoo#33841

Signed-off-by: default avatarNans Lefebvre (len) <len@odoo.com>
parent 58d414ec
Branches
Tags
No related merge requests found
......@@ -80,9 +80,9 @@ class AccountInvoice(models.Model):
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 vendor_ref and (not self.reference or (
vendor_ref + ", " not in self.reference and not self.reference.endswith(vendor_ref))):
self.reference = ", ".join([self.reference, vendor_ref]) if self.reference else vendor_ref
new_lines = self.env['account.invoice.line']
for line in self.purchase_id.order_line - self.invoice_line_ids.mapped('purchase_line_id'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment