From ed6a52a5177349d41f2a589596d9ddfc312b8dff Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Tue, 22 Dec 2015 15:08:15 +0100 Subject: [PATCH] [FIX] sale: no more refund invoices overload When fetching the invoices linked to a sales order, the system looked for all refunds which had an 'origin' field that was the number of an invoice of this SO. That's nice, except that invoices that are not yet validated do not have a number, which caused sales order with an uncofirmed invoices to be 'linked' to all 'out_invoices' that had no origin (which could be 1000+ for a substantial db) (basically all out invoices which had the origin field set to false) This commit simply extends the domain to exclude refunds that did not originate explicitly from one of the SO's invoices. --- addons/sale/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 1525429904a..bfaea2e26d0 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -55,7 +55,7 @@ class SaleOrder(models.Model): # Search for refunds as well refund_ids = self.env['account.invoice'].browse() if invoice_ids: - refund_ids = refund_ids.search([('type', '=', 'out_refund'), ('origin', 'in', invoice_ids.mapped('number'))]) + refund_ids = refund_ids.search([('type', '=', 'out_refund'), ('origin', 'in', invoice_ids.mapped('number')), ('origin', '!=', False)]) line_invoice_status = [line.invoice_status for line in order.order_line]