diff --git a/CHANGELOG b/CHANGELOG index 447825f3fb..3e4875a3fb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow skipping user warnings globally * Add validate option to trytond-admin * Refresh pool of other processes * Add clear_all method to Cache diff --git a/doc/topics/user_errors_warnings.rst b/doc/topics/user_errors_warnings.rst index 5f50891c50..72980cb56d 100644 --- a/doc/topics/user_errors_warnings.rst +++ b/doc/topics/user_errors_warnings.rst @@ -63,3 +63,7 @@ Example: warning_name = 'mywarning,%s' % self if Warning.check(warning_name): raise UserWarning(warning_name, "Process cannot be canceled.") + +.. note:: + If there is no user interaction the warnings can be skipped by setting the + ``_skip_warnings`` key of the context to ``True``. diff --git a/trytond/res/user.py b/trytond/res/user.py index e54892910a..5a03fa236e 100644 --- a/trytond/res/user.py +++ b/trytond/res/user.py @@ -909,8 +909,10 @@ class Warning_(ModelSQL, ModelView): @classmethod def check(cls, warning_name): - user = Transaction().user - if not user: + transaction = Transaction() + user = transaction.user + context = transaction.context + if not user or context.get('_skip_warnings'): return False warnings = cls.search([ ('user', '=', user),