changeset 4c66434fc3c7 in modules/stock:default details: https://hg.tryton.org/modules/stock?cmd=changeset&node=4c66434fc3c7 description: Do not check access when checking for period closed
issue11861 review431871003 diffstat: move.py | 31 ++++++++++++++++--------------- 1 files changed, 16 insertions(+), 15 deletions(-) diffs (41 lines): diff -r af8a0f9a361d -r 4c66434fc3c7 move.py --- a/move.py Mon Oct 31 16:54:14 2022 +0100 +++ b/move.py Sat Nov 05 10:08:31 2022 +0100 @@ -544,21 +544,22 @@ @classmethod def check_period_closed(cls, moves): Period = Pool().get('stock.period') - for company, moves in groupby(moves, lambda m: m.company): - periods = Period.search([ - ('state', '=', 'closed'), - ('company', '=', company.id), - ], order=[('date', 'DESC')], limit=1) - if periods: - period, = periods - for move in moves: - date = (move.effective_date if move.effective_date - else move.planned_date) - if date and date <= period.date: - raise AccessError( - gettext('stock.msg_move_modify_period_close', - move=move.rec_name, - period=period.rec_name)) + with Transaction().set_context(_check_access=False): + for company, moves in groupby(moves, lambda m: m.company): + periods = Period.search([ + ('state', '=', 'closed'), + ('company', '=', company.id), + ], order=[('date', 'DESC')], limit=1) + if periods: + period, = periods + for move in moves: + date = (move.effective_date if move.effective_date + else move.planned_date) + if date and date <= period.date: + raise AccessError( + gettext('stock.msg_move_modify_period_close', + move=move.rec_name, + period=period.rec_name)) def get_rec_name(self, name): pool = Pool()