From 906c1e52fb20c769fbab7dc016fefb2891a50bac Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 13 Oct 2015 09:39:19 +0200 Subject: [PATCH] [FIX] base: don't add last separator if no add attribute When using "remove" in a xml inheritance without "add" attribute, the separator would be erronously appended at the end of the modified attribute value. e.g: we have "a,b" from which we remove "c", the end result would be "a,b," which is an invalid jQuery selector. This commit change this so empty tokens are not added to the attribute. --- openerp/addons/base/ir/ir_ui_view.py | 2 +- openerp/addons/base/tests/test_views.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py index d19e3e7dae2..ba5f72f0f62 100644 --- a/openerp/addons/base/ir/ir_ui_view.py +++ b/openerp/addons/base/ir/ir_ui_view.py @@ -539,7 +539,7 @@ class view(osv.osv): separator = child.get('separator', ',') if separator == ' ': separator = None # squash spaces - to_add = map(str.strip, child.get('add', '').split(separator)) + to_add = filter(bool, map(str.strip, child.get('add', '').split(separator))) to_remove = map(str.strip, child.get('remove', '').split(separator)) values = map(str.strip, node.get(attribute, '').split(separator)) value = (separator or ' ').join(filter(lambda s: s not in to_remove, values) + to_add) diff --git a/openerp/addons/base/tests/test_views.py b/openerp/addons/base/tests/test_views.py index 57a491fc20f..c0358c29189 100644 --- a/openerp/addons/base/tests/test_views.py +++ b/openerp/addons/base/tests/test_views.py @@ -746,7 +746,7 @@ class test_views(ViewCase): bob tata lolo bob, tata,lolo - + """ }) @@ -766,7 +766,7 @@ class test_views(ViewCase): E.p("Replacement data"), E.footer( E.button(name="action_next", type="object", string="New button"), - thing="bob lolo bibi and co", otherthing="lolo,bibi" + thing="bob lolo bibi and co", otherthing="lolo" ), string="Replacement title", version="7.0"))