diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-11-30 15:39:30 +0000 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-12-03 08:45:05 +0000 |
| commit | 9d1aa41bfbafce072bae672b3a329da99fca712f (patch) | |
| tree | 718eebb90a5f536903b76cd9da76bf25885e9da5 | |
| parent | 31d1a62bb38b41f4e40d09dcbc7b65ab7b0d5c9c (diff) | |
[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
| -rw-r--r-- | addons/account/models/account_invoice.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 58fab13d628..a16dfcb83f5 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -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' |
