[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
This commit is contained in:
Yenthe V.G
2018-11-07 13:08:57 +01:00
committed by qdp-odoo
parent df057df5a9
commit e6ff16cbba
+2 -1
View File
@@ -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