From 9671ae2a2d116cd1d8f6196b125b92b95ce98f6f Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 28 Sep 2015 14:45:29 +0200 Subject: [PATCH] [FIX] models: onchange warnings concatenation This revision is related 420e198aa522039cefeeb65fa318207e5dc9b8d8. onchanges can return "False" as warning value. In such a case, prevent the concatenation with previous results. --- openerp/models.py | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/openerp/models.py b/openerp/models.py index 40c04992287..4f7c5dd795a 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -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