[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user