changeset b6db31f4ffb9 in modules/stock:6.0
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=b6db31f4ffb9
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 51a51197018e -r b6db31f4ffb9 move.py
--- a/move.py   Mon Oct 17 23:54:21 2022 +0200
+++ b/move.py   Sat Nov 05 10:08:31 2022 +0100
@@ -554,21 +554,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()

Reply via email to