From e6ff16cbba3802ca17c7bc110d91674580edd38b Mon Sep 17 00:00:00 2001 From: "Yenthe V.G" Date: Wed, 7 Nov 2018 12:04:17 +0100 Subject: [PATCH] [FIX] sale: fix type of created invoice from SO Consider the generation of an invoice for a SO having the following lines: quantity | unit price | taxes | subtotal ---------------------------------------- 1 | 100 | 15% | 115 1 | -110 | | -110 Previously, the invoice wrongly received the type 'out_refund' instead of 'out_invoice'. This was because the code was only considering the untaxed amount. Closes #28259 Fixes #26726 Co-authored by pedrobaeza --- addons/sale/models/sale.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index f226767ba6f..eabb9a28912 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -372,10 +372,11 @@ class SaleOrder(models.Model): raise UserError(_('There is no invoicable line.')) for invoice in invoices.values(): + invoice.compute_taxes() if not invoice.invoice_line_ids: raise UserError(_('There is no invoicable line.')) # If invoice is negative, do a refund invoice instead - if invoice.amount_untaxed < 0: + if invoice.amount_total < 0: invoice.type = 'out_refund' for line in invoice.invoice_line_ids: line.quantity = -line.quantity