changeset 86ae1d7b27a5 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=86ae1d7b27a5
description:
        Disable record rule when validating records

        issue9796
        review329451002
diffstat:

 trytond/model/modelstorage.py |  9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diffs (26 lines):

diff -r c3e38f487a9b -r 86ae1d7b27a5 trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py     Fri Nov 06 00:51:27 2020 +0100
+++ b/trytond/model/modelstorage.py     Wed Nov 11 20:33:18 2020 +0100
@@ -81,6 +81,14 @@
     return wrapper
 
 
+def without_rule(func):
+    @wraps(func)
+    def wrapper(*args, **kwargs):
+        with Transaction().set_user(0):
+            return func(*args, **kwargs)
+    return wrapper
+
+
 def cache_size():
     return Transaction().context.get('_record_cache_size', _cache_record)
 
@@ -1038,6 +1046,7 @@
 
     @classmethod
     @without_check_access
+    @without_rule
     def _validate(cls, records, field_names=None):
         pool = Pool()
         # Ensure that records are readable

Reply via email to