[FIX] account: randomize invoice reference if no match

Take explanation of
commit d94e8a0
but this time, have a suffix with a flavor of %(year)s

Before this commit, validating the invoice crashes

After this commit it doesn't.

OPW 1912954

closes odoo/odoo#29160
This commit is contained in:
Lucas Perais (lpe)
2018-12-03 08:45:05 +00:00
parent 31d1a62bb3
commit 9d1aa41bfb
+6 -1
View File
@@ -397,7 +397,12 @@ class AccountInvoice(models.Model):
if self.company_id.invoice_reference_type == 'invoice_number':
seq_suffix = self.journal_id.sequence_id.suffix or ''
regex_number = '.*?([0-9]+)%s$' % seq_suffix
identification_number = int(re.match(regex_number, self.number).group(1))
exact_match = re.match(regex_number, self.number)
if exact_match:
identification_number = int(exact_match.group(1))
else:
ran_num = str(uuid.uuid4().int)
identification_number = int(ran_num[:5] + ran_num[-5:])
prefix = self.number
else:
#self.company_id.invoice_reference_type == 'partner'