From 4091d5823450e994dfdfe810e57ec4cdee54c6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 16 Aug 2021 23:08:50 +0200 Subject: [PATCH] Use company of the move created to retrieve the numbering sequence issue10634 review342831004 (grafted from af10119a0c2a075bc43c55a7e23261d4578fd71c) --HG-- branch : 6.0 --- move.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/move.py b/move.py index 4ec2b1275b..017e2c4a40 100644 --- a/move.py +++ b/move.py @@ -270,16 +270,24 @@ class Move(ModelSQL, ModelView): def create(cls, vlist): pool = Pool() Journal = pool.get('account.journal') + context = Transaction().context + journals = {} + default_company = cls.default_company() vlist = [x.copy() for x in vlist] for vals in vlist: if not vals.get('number'): - journal_id = (vals.get('journal') - or Transaction().context.get('journal')) + journal_id = vals.get('journal', context.get('journal')) + company_id = vals.get('company', default_company) if journal_id: - journal = Journal(journal_id) - if journal.sequence: - vals['number'] = journal.sequence.get() + if journal_id not in journals: + journal = journals[journal_id] = Journal(journal_id) + else: + journal = journals[journal_id] + sequence = journal.get_multivalue( + 'sequence', company=company_id) + if sequence: + vals['number'] = sequence.get() moves = super(Move, cls).create(vlist) cls.validate_move(moves)