From 021bb82d44f9873670550dcd4501cbbf5d4052e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Tarroja=20Caubet?= Date: Sat, 5 Nov 2022 10:08:31 +0100 Subject: [PATCH] Do not check access when checking for period closed issue11861 review431871003 (grafted from 4c66434fc3c739c80840165bfb4cfc48c5932e7b) --HG-- branch : 6.0 --- move.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/move.py b/move.py index 391c11094d..19518495dd 100644 --- a/move.py +++ b/move.py @@ -554,21 +554,22 @@ class Move(Workflow, ModelSQL, ModelView): @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()