Skip lines without product to determine if invoice is credit_note

Also don't consider lines with zero amount as credit notes

issue6253
review35261002
This commit is contained in:
Sergi Almacellas Abellana committed 2017-03-01 09:58:30 +01:00
1 parent df114ea281
commit 604b6eebd0
1 file changed
+2 -1
+2 -1
View File
@@ -1008,7 +1008,8 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
date=accounting_date, test_state=test_state)
period = Period(period_id)
invoice_type = invoice.type
if all(l.amount <= 0 for l in invoice.lines):
if (all(l.amount < 0 for l in invoice.lines if l.product)
and invoice.total_amount < 0):
invoice_type += '_credit_note'
else:
invoice_type += '_invoice'