[FIX] models: multiple warnings in onchanges
If multiple warnings were returned by a cascading onchange call, only the last warning was displayed. This revision concatenates the warnings in such a case. opw-649275
This commit is contained in:
parent
a2388c762e
commit
420e198aa5
|
@ -5782,6 +5782,17 @@ class BaseModel(object):
|
|||
if 'domain' in method_res:
|
||||
result.setdefault('domain', {}).update(method_res['domain'])
|
||||
if 'warning' in method_res:
|
||||
if 'warning' in result:
|
||||
# Concatenate multiple warnings
|
||||
warning = result['warning']
|
||||
warning['message'] = '\n\n'.join(filter(None, [
|
||||
warning.get('title'),
|
||||
warning.get('message'),
|
||||
method_res['warning'].get('title'),
|
||||
method_res['warning'].get('message')
|
||||
]))
|
||||
warning['title'] = _('Warnings')
|
||||
else:
|
||||
result['warning'] = method_res['warning']
|
||||
return
|
||||
|
||||
|
@ -5823,8 +5834,18 @@ class BaseModel(object):
|
|||
if 'domain' in method_res:
|
||||
result.setdefault('domain', {}).update(method_res['domain'])
|
||||
if 'warning' in method_res:
|
||||
if 'warning' in result:
|
||||
# Concatenate multiple warnings
|
||||
warning = result['warning']
|
||||
warning['message'] = '\n\n'.join(filter(None, [
|
||||
warning.get('title'),
|
||||
warning.get('message'),
|
||||
method_res['warning'].get('title'),
|
||||
method_res['warning'].get('message')
|
||||
]))
|
||||
warning['title'] = _('Warnings')
|
||||
else:
|
||||
result['warning'] = method_res['warning']
|
||||
|
||||
@api.multi
|
||||
def onchange(self, values, field_name, field_onchange):
|
||||
""" Perform an onchange on the given field.
|
||||
|
|
Loading…
Reference in New Issue