changeset dc97ce40c5ad in modules/stock:6.4
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=dc97ce40c5ad
description:
Do not check access when checking for period closed
issue11861
review431871003
(grafted from 4c66434fc3c739c80840165bfb4cfc48c5932e7b)
diffstat:
move.py | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diffs (41 lines):
diff -r 596e0f9beb68 -r dc97ce40c5ad move.py
--- a/move.py Sat Nov 05 18:00:10 2022 +0100
+++ b/move.py Sat Nov 05 10:08:31 2022 +0100
@@ -529,21 +529,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()