[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.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -746,7 +746,7 @@ class test_views(ViewCase):
|
||||
<attribute name="thing">bob tata lolo</attribute>
|
||||
<attribute name="thing" add="bibi and co" remove="tata" separator=" " />
|
||||
<attribute name="otherthing">bob, tata,lolo</attribute>
|
||||
<attribute name="otherthing" add="bibi" remove="tata, bob"/>
|
||||
<attribute name="otherthing" remove="tata, bob"/>
|
||||
</footer>
|
||||
"""
|
||||
})
|
||||
@@ -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"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user