Allow skipping user warnings globally
issue7442 review318871002
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user