Allow skipping user warnings globally

issue7442
review318871002
This commit is contained in:
Adrià Tarroja Caubet
2021-02-05 00:21:10 +01:00
parent 4dc66f6f7c
commit 2ba3e1bdb6
3 changed files with 9 additions and 2 deletions
+1
View File
@@ -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
+4
View File
@@ -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``.
+4 -2
View File
@@ -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),