[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:
Denis Ledoux 2015-09-28 12:03:55 +02:00
parent a2388c762e
commit 420e198aa5
1 changed files with 24 additions and 3 deletions

View File

@ -5782,7 +5782,18 @@ class BaseModel(object):
if 'domain' in method_res:
result.setdefault('domain', {}).update(method_res['domain'])
if 'warning' in method_res:
result['warning'] = method_res['warning']
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
# onchange V7
@ -5823,8 +5834,18 @@ class BaseModel(object):
if 'domain' in method_res:
result.setdefault('domain', {}).update(method_res['domain'])
if 'warning' in method_res:
result['warning'] = method_res['warning']
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.