add account_invoice_criteria patch

This commit is contained in:
?ngel ?lvarez 2018-02-07 15:51:23 +01:00
parent 6e286c100f
commit 1ff303a8e3
2 changed files with 29 additions and 0 deletions

28
issue6253.diff Normal file
View File

@ -0,0 +1,28 @@
diff -r 6c85f394741c invoice.py
--- a/modules/account_invoice/invoice.py Wed Jan 24 20:14:28 2018 +0100
+++ b/modules/account_invoice/invoice.py Wed Feb 07 15:39:49 2018 +0100
@@ -1020,6 +1020,11 @@
invoice.number = invoice.get_next_number()
cls.save(invoices)
+ def invoice_type_criteria(self):
+ if self.base_amount < 0:
+ 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)
- 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):

1
series Normal file
View File

@ -0,0 +1 @@
issue6253.diff # add invoice type criteria