[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.
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user