From 750ad14bb2502d7bed8feeb4f39e08cb61e9a5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 29 Jan 2020 00:03:40 +0100 Subject: [PATCH] Skip trigger using contextual key Relying on the user is not flexible enough. issue8993 review260841002 --- trytond/ir/trigger.py | 2 +- trytond/modules/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/trytond/ir/trigger.py b/trytond/ir/trigger.py index b7e581e0d7..222248d2d3 100644 --- a/trytond/ir/trigger.py +++ b/trytond/ir/trigger.py @@ -147,7 +147,7 @@ class Trigger(DeactivableMixin, ModelSQL, ModelView): assert mode in ['create', 'write', 'delete', 'time'], \ 'Invalid trigger mode' - if Transaction().user == 0 and not Transaction().context.get('user'): + if Transaction().context.get('_no_trigger'): return [] key = (model_name, mode) diff --git a/trytond/modules/__init__.py b/trytond/modules/__init__.py index 2ce35676b7..c40f503221 100644 --- a/trytond/modules/__init__.py +++ b/trytond/modules/__init__.py @@ -352,7 +352,8 @@ def load_modules( global res transaction = Transaction() - with transaction.connection.cursor() as cursor: + with transaction.set_context(_no_trigger=True), \ + transaction.connection.cursor() as cursor: # Migration from 3.6: remove double module old_table = 'ir_module_module' new_table = 'ir_module'