[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.
This commit is contained in:
Damien Bouvy
2015-12-23 11:51:48 +01:00
parent c7337bf3b3
commit ed6a52a517
+1 -1
View File
@@ -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]