Permalink
Browse files

[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
  • Loading branch information...
Yenthe666 authored and qdp-odoo committed Nov 7, 2018
1 parent df057df commit e6ff16cbba3802ca17c7bc110d91674580edd38b
Showing with 2 additions and 1 deletion.
  1. +2 −1 addons/sale/models/sale.py
@@ -372,10 +372,11 @@ def action_invoice_create(self, grouped=False, final=False):
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

0 comments on commit e6ff16c

Please sign in to comment.