From a315487cea16647c2a54e446e7c85dd46ec45b3f Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Thu, 8 Oct 2015 16:01:01 +0200 Subject: [PATCH] [FIX] sale: when creating a refun from an invoice, the invoice lines must be linked to the original so lines to compute the invoiced quantity correctly Since invoice quantities are computed from the invoice lines linked to the so line via a many2many field, we need to overload the refund function that adds the fields on the invoice lines; explicitly copying the sale order lines references. --- addons/sale/sale.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 165348c2ba6..61111c80172 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -785,6 +785,13 @@ class AccountInvoice(models.Model): order.message_post(body=_("Invoice %s paid") % (name)) return res + @api.model + def _refund_cleanup_lines(self, lines): + result = super(AccountInvoice, self)._refund_cleanup_lines(lines) + for index, line in enumerate(lines): + result[index][2]['sale_line_ids'] = [(6, 0, line.sale_line_ids.ids)] + return result + class AccountInvoiceLine(models.Model): _inherit = 'account.invoice.line'