From 97b79a198564ecff1007b218b475ad2aaac3d270 Mon Sep 17 00:00:00 2001 From: Martin Trigaux <mat@odoo.com> Date: Wed, 11 May 2016 15:59:38 +0200 Subject: [PATCH] [FIX] sale: exact matching on origin Avoid that an invoice for 'SO042' matches with the invoices of 'SO04'. The use of the like is required as it may contains more than one reference to an invoice. opw-676921 --- addons/sale/sale.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 6e6e44203b9f..4176d75229a3 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -54,7 +54,9 @@ class SaleOrder(models.Model): invoice_ids = order.order_line.mapped('invoice_lines').mapped('invoice_id') # Search for invoices which have been 'cancelled' (filter_refund = 'modify' in # 'account.invoice.refund') - invoice_ids |= invoice_ids.search([('origin', 'like', order.name)]) + # use like as origin may contains multiple references (e.g. 'SO01, SO02') + refunds = invoice_ids.search([('origin', 'like', order.name)]) + invoice_ids |= refunds.filtered(lambda r: order.name in [origin.strip() for origin in r.origin.split(',')]) # Search for refunds as well refund_ids = self.env['account.invoice'].browse() if invoice_ids: -- GitLab