[FIX] account: add support for format like 045-001-000002

Before this fix, the prefix was detected as `045-0` and the year as `1`
instead of no year with prefix `045-001`.

opw-2381351

closes odoo/odoo#61931

X-original-commit: e1b4521e82af1c865d69e9e0cf637713d0b94480
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
wan
2020-11-18 12:07:09 +00:00
parent 2356bc1722
commit 260bb5a540
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -20,8 +20,8 @@ class SequenceMixin(models.AbstractModel):
_sequence_field = "name"
_sequence_date_field = "date"
_sequence_index = False
_sequence_monthly_regex = r'^(?P<prefix1>.*?)(?P<year>(\d{4}|(\d{2}(?=\D))))(?P<prefix2>\D*?)(?P<month>\d{2})(?P<prefix3>\D+?)(?P<seq>\d*)(?P<suffix>\D*?)$'
_sequence_yearly_regex = r'^(?P<prefix1>.*?)(?P<year>(\d{4}|\d{2}))(?P<prefix2>\D+?)(?P<seq>\d*)(?P<suffix>\D*?)$'
_sequence_monthly_regex = r'^(?P<prefix1>.*?)(?P<year>((?<=\D)|(?<=^))(\d{4}|(\d{2}(?=\D))))(?P<prefix2>\D*?)(?P<month>\d{2})(?P<prefix3>\D+?)(?P<seq>\d*)(?P<suffix>\D*?)$'
_sequence_yearly_regex = r'^(?P<prefix1>.*?)(?P<year>((?<=\D)|(?<=^))(\d{4}|\d{2}))(?P<prefix2>\D+?)(?P<seq>\d*)(?P<suffix>\D*?)$'
_sequence_fixed_regex = r'^(?P<prefix1>.*?)(?P<seq>\d{0,9})(?P<suffix>\D*?)$'
sequence_prefix = fields.Char(compute='_compute_split_sequence', store=True)
@@ -416,6 +416,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
('201603-10', '201603-11', '201604-01', '201703-01'),
('16-03-10', '16-03-11', '16-04-01', '17-03-01'),
('2016-10', '2016-11', '2016-12', '2017-01'),
('045-001-000002', '045-001-000003', '045-001-000004', '045-001-000005'),
('JRNL/2016/00001suffix', 'JRNL/2016/00002suffix', 'JRNL/2016/00003suffix', 'JRNL/2017/00001suffix'),
]
other_moves = self.env['account.move'].search([('journal_id', '=', self.test_move.journal_id.id)]) - self.test_move