changeset cf2cc39bf833 in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset;node=cf2cc39bf833
description:
        Use root user to evaluate user environment

        The user attributes may be restricted by other record rules so to 
evaluate the
        domain, we must have access to all attributes.

        issue9901
        review333341002
        (grafted from 470e029c49eed8c844c5b0cb1961d8fcf1ada7da)
diffstat:

 trytond/ir/rule.py |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (16 lines):

diff -r 5a81202f8af7 -r cf2cc39bf833 trytond/ir/rule.py
--- a/trytond/ir/rule.py        Sun Nov 29 11:30:45 2020 +0000
+++ b/trytond/ir/rule.py        Wed Dec 16 20:41:21 2020 +0100
@@ -140,8 +140,10 @@
     @staticmethod
     def _get_context():
         User = Pool().get('res.user')
-        user_id = Transaction().user
-        with Transaction().set_context(_check_access=False, _datetime=None):
+        transaction = Transaction()
+        user_id = transaction.user
+        with transaction.set_context(_check_access=False, _datetime=None), \
+                transaction.set_user(0):
             user = EvalEnvironment(User(user_id), User)
         return {
             'user': user,

Reply via email to