diff options
| author | Nans Lefebvre <len@odoo.com> | 2019-06-03 13:26:24 +0000 |
|---|---|---|
| committer | Nans Lefebvre <len@odoo.com> | 2019-06-03 13:30:42 +0000 |
| commit | ff4f3922a9dd018fee7c855894fc27f588dd6dcd (patch) | |
| tree | 701109e3e5c8c33ce1634aab8a237eb01804bf71 | |
| parent | 58d414ec1c0c1559435eb3fc9ebdc5cf549efa4f (diff) | |
[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: Nans Lefebvre (len) <len@odoo.com>
| -rw-r--r-- | addons/purchase/models/account_invoice.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 151465498a6..946723fa524 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -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'): |
