From d563481306f10fe1b634a06ecb8a9b894d0bcb4e Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Mon, 24 Apr 2023 15:49:56 +0000 Subject: [PATCH] [FIX] purchase: vendor bill autocomplete check for duplicated lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Failing use case: Create a vendor bill and use the auto-complete field to select a purchase order multiple times. The purchase order gets added to the vendor bill multiple times, this doesn't happen in V15 and was never intended. The reason is simply that the code was checking on self.line_ids which get only populated after the record is saved and its invoice_line_ids are synchronized. Before that, only the field invoice_line_ids is filled witht new_ids. opw - 3196149 closes odoo/odoo#119758 X-original-commit: 29d5862d447dd369432b345e43d5875d3b2a4474 Signed-off-by: William André (wan) --- addons/purchase/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 65c3a13e1ad..0f39a58045b 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -60,7 +60,7 @@ class AccountMove(models.Model): self.update(invoice_vals) # Copy purchase lines. - po_lines = self.purchase_id.order_line - self.line_ids.mapped('purchase_line_id') + po_lines = self.purchase_id.order_line - self.invoice_line_ids.mapped('purchase_line_id') for line in po_lines.filtered(lambda l: not l.display_type): self.invoice_line_ids += self.env['account.move.line'].new( line._prepare_account_move_line(self)