From 9b73ee7bdb79ebd9972783712ddba45f1ba04cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 22 Dec 2023 16:57:43 +0100 Subject: [PATCH] Do not check warnings with access checked The user does not have access right to delete warnings. Closes #12861 (grafted from 9b820b67b9107ed87113297ebd10bc5bd2309181) --HG-- branch : 6.0 --- modules/stock_supply/stock.py | 43 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/modules/stock_supply/stock.py b/modules/stock_supply/stock.py index a5614d5e26..51583eb1d3 100644 --- a/modules/stock_supply/stock.py +++ b/modules/stock_supply/stock.py @@ -43,26 +43,29 @@ class Supply(Wizard): Warning = pool.get('res.user.warning') today = Date.today() with Transaction().set_context(_check_access=True): - if Move.search([ - ('from_location.type', '=', 'supplier'), - ('to_location.type', '=', 'storage'), - ('state', '=', 'draft'), - ('planned_date', '<', today), - ], order=[]): - name = '%s.supplier@%s' % (self.__name__, today) - if Warning.check(name): - raise SupplyWarning(name, - gettext('stock_supply.msg_late_supplier_moves')) - if Move.search([ - ('from_location.type', '=', 'storage'), - ('to_location.type', '=', 'customer'), - ('state', '=', 'draft'), - ('planned_date', '<', today), - ], order=[]): - name = '%s..customer@%s' % (self.__name__, today) - if Warning.check(name): - raise SupplyWarning(name, - gettext('stock_supply.msg_late_customer_moves')) + moves = Move.search([ + ('from_location.type', '=', 'supplier'), + ('to_location.type', '=', 'storage'), + ('state', '=', 'draft'), + ('planned_date', '<', today), + ], order=[], limit=1) + if moves: + name = '%s.supplier@%s' % (self.__name__, today) + if Warning.check(name): + raise SupplyWarning(name, + gettext('stock_supply.msg_late_supplier_moves')) + with Transaction().set_context(_check_access=True): + moves = Move.search([ + ('from_location.type', '=', 'storage'), + ('to_location.type', '=', 'customer'), + ('state', '=', 'draft'), + ('planned_date', '<', today), + ], order=[], limit=1) + if moves: + name = '%s..customer@%s' % (self.__name__, today) + if Warning.check(name): + raise SupplyWarning(name, + gettext('stock_supply.msg_late_customer_moves')) first = True created = False