[FIX] models: onchange warnings concatenation

This revision is related 420e198aa5.

onchanges can return "False" as warning value.
In such a case, prevent the concatenation with previous results.
This commit is contained in:
Denis Ledoux 2015-09-28 14:45:29 +02:00
parent 5f79cbd029
commit 9671ae2a2d
1 changed files with 22 additions and 20 deletions

View File

@ -5782,16 +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')
if result.get('warning'):
if method_res['warning']:
# 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
@ -5834,16 +5835,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')
if result.get('warning'):
if method_res['warning']:
# 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