changeset ef88d61b9594 in trytond:default details: https://hg.tryton.org/trytond?cmd=changeset;node=ef88d61b9594 description: Allow skipping user warnings globally
issue7442 review318871002 diffstat: CHANGELOG | 1 + doc/topics/user_errors_warnings.rst | 4 ++++ trytond/res/user.py | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diffs (35 lines): diff -r 38abefa3d955 -r ef88d61b9594 CHANGELOG --- a/CHANGELOG Wed Feb 03 23:26:07 2021 +0100 +++ b/CHANGELOG Fri Feb 05 00:21:10 2021 +0100 @@ -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 -r 38abefa3d955 -r ef88d61b9594 doc/topics/user_errors_warnings.rst --- a/doc/topics/user_errors_warnings.rst Wed Feb 03 23:26:07 2021 +0100 +++ b/doc/topics/user_errors_warnings.rst Fri Feb 05 00:21:10 2021 +0100 @@ -63,3 +63,7 @@ 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 -r 38abefa3d955 -r ef88d61b9594 trytond/res/user.py --- a/trytond/res/user.py Wed Feb 03 23:26:07 2021 +0100 +++ b/trytond/res/user.py Fri Feb 05 00:21:10 2021 +0100 @@ -909,8 +909,10 @@ @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),