From ede1d6f9aa16cae535d650da3191bb6a6d86f793 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Sun, 3 Dec 2023 17:38:57 +0100 Subject: [PATCH] [FIX] access release channel code with sudo users may not have system group, they can't access to the code field --- stock_release_channel/models/stock_release_channel.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stock_release_channel/models/stock_release_channel.py b/stock_release_channel/models/stock_release_channel.py index f37a2e1c10..ffdeac7283 100644 --- a/stock_release_channel/models/stock_release_channel.py +++ b/stock_release_channel/models/stock_release_channel.py @@ -485,13 +485,14 @@ def assign_release_channel(self, picking): for channel in picking._find_release_channel_possible_candidate(): current = picking domain = channel._prepare_domain() - if not domain and not channel.code: + code = channel.sudo().code + if not domain and not code: current.release_channel_id = channel if domain: current = picking.filtered_domain(domain) if not current: continue - if channel.code: + if code: current = channel._eval_code(current) if not current: continue @@ -535,7 +536,8 @@ def _eval_context(self, pickings): return eval_context def _eval_code(self, pickings): - expr = self.code.strip() + code = self.sudo().code + expr = code.strip() eval_context = self._eval_context(pickings) try: safe_eval(expr, eval_context, mode="exec", nocopy=True)