Do not check access when checking for period closed

issue11861
review431871003
This commit is contained in:
Adrià Tarroja Caubet
2022-11-05 10:08:31 +01:00
parent 9711c32d23
commit 612ec03dce
+16 -15
View File
@@ -544,21 +544,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()