Use dedicated method to skip user warning
This commit is contained in:
+2
-6
@@ -48,12 +48,8 @@
|
||||
return;
|
||||
}
|
||||
Sao.rpc({
|
||||
'method': 'model.res.user.warning.create',
|
||||
'params': [[{
|
||||
'user': session.user_id,
|
||||
'name': name,
|
||||
'always': result == 'always'
|
||||
}], {}]
|
||||
'method': 'model.res.user.warning.skip',
|
||||
'params': [name, result == 'always', {}],
|
||||
}, session).done(function() {
|
||||
if (async) {
|
||||
Sao.rpc(args, session).then(
|
||||
|
||||
@@ -973,11 +973,9 @@ def process_exception(exception, *args, **kwargs):
|
||||
name, msg, description = exception.args
|
||||
res = userwarning(description, msg)
|
||||
if res in ('always', 'ok'):
|
||||
RPCExecute('model', 'res.user.warning', 'create', [{
|
||||
'user': rpc._USER,
|
||||
'name': name,
|
||||
'always': (res == 'always'),
|
||||
}],
|
||||
RPCExecute(
|
||||
'model', 'res.user.warning', 'skip',
|
||||
name, (res == 'always'),
|
||||
process_exception=False)
|
||||
return rpc_execute(*args)
|
||||
elif exception.faultCode == 'UserError':
|
||||
|
||||
@@ -1073,6 +1073,22 @@ class Warning_(ModelSQL, ModelView):
|
||||
name = fields.Char('Name', required=True)
|
||||
always = fields.Boolean('Always')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls.__access__.add('user')
|
||||
cls.__rpc__.update(
|
||||
skip=RPC(check_access=False, readonly=False),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def skip(cls, name, always=False):
|
||||
cls.create([{
|
||||
'name': name,
|
||||
'user': Transaction().user,
|
||||
'always': always,
|
||||
}])
|
||||
|
||||
@classmethod
|
||||
def format(cls, name, records):
|
||||
key = '|'.join(map(str, records)).encode('utf-8')
|
||||
|
||||
Reference in New Issue
Block a user