[FIX] sale: refunds with _get_invoiced

Steps to reproduce:

-Create a first journal with a sequence
-Create a second journal with the same sequence
-Create a first SO, create the invoice for the fist journal and validate it
-Create a second SO, create the invoice for the second journal and validate it (the second invoice has the exact same name as the first one)
-Refund the second invoice (linked to the second SO)
-Go to the first SO => In the invoice button, you see 2 linked invoices (there is normally only one)

When searching the refunds corresponding to the invoices in function
_get_invoiced, the refund must take the journal of the invoice into account.

opw:684144
This commit is contained in:
Goffin Simon
2016-08-02 09:36:35 +02:00
parent ce419242d0
commit 9bb16c5ce1
+2 -1
View File
@@ -60,7 +60,8 @@ 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')), ('origin', '!=', False)])
for inv in invoice_ids:
refund_ids += refund_ids.search([('type', '=', 'out_refund'), ('origin', '=', inv.number), ('origin', '!=', False), ('journal_id', '=', inv.journal_id.id)])
line_invoice_status = [line.invoice_status for line in order.order_line]