trytond-patches/issue6253.diff

29 lines
1.1 KiB
Diff
Raw Normal View History

2018-02-07 15:51:23 +01:00
diff -r 6c85f394741c invoice.py
2018-05-07 14:23:08 +02:00
--- a/trytond/trytond/modules/account_invoice/invoice.py Wed Jan 24 20:14:28 2018 +0100
+++ b/trytond/trytond/modules/account_invoice/invoice.py Wed Feb 07 15:39:49 2018 +0100
2018-02-07 15:51:23 +01:00
@@ -1020,6 +1020,11 @@
invoice.number = invoice.get_next_number()
cls.save(invoices)
+ def invoice_type_criteria(self):
2018-02-14 17:57:26 +01:00
+ if self.untaxed_amount < 0:
2018-02-07 15:51:23 +01:00
+ return '_credit_note'
+ return '_invoice'
+
def get_next_number(self, pattern=None):
pool = Pool()
Sequence = pool.get('ir.sequence.strict')
@@ -1040,11 +1045,7 @@
pattern.setdefault('fiscalyear', fiscalyear.id)
pattern.setdefault('period', period.id)
invoice_type = self.type
- if (all(l.amount <= 0 for l in self.lines if l.product)
2018-02-07 15:51:23 +01:00
- and self.total_amount < 0):
- invoice_type += '_credit_note'
- else:
- invoice_type += '_invoice'
+ invoice_type += self.invoice_type_criteria()
for invoice_sequence in fiscalyear.invoice_sequences:
if invoice_sequence.match(pattern):