From 9bb16c5ce1880d57626ec975a8ed5e78b69d300b Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 1 Aug 2016 17:08:13 +0200 Subject: [PATCH] [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 --- addons/sale/sale.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 1836f6a2fca..a3b839fd781 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -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]