From 75bf28388b9c2904576aedc43b61620665ee9cd0 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 11 Apr 2011 08:25:41 +0200 Subject: [PATCH] [IMP] improvements to View.normalize_attrs bzr revid: xmo@openerp.com-20110411062541-mjib0mm8wk7ujlyy --- addons/base/controllers/main.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/addons/base/controllers/main.py b/addons/base/controllers/main.py index 96782c1cec4..efc960168c4 100644 --- a/addons/base/controllers/main.py +++ b/addons/base/controllers/main.py @@ -424,19 +424,16 @@ class View(openerpweb.Controller): :param dict context: evaluation context """ # If @attrs is normalized in json by server, the eval should be replaced by simplejson.loads - attrs = eval(elem.attrib.get('attrs', '{}')) + attrs = openerpweb.ast.literal_eval(elem.get('attrs', '{}')) if 'states' in elem.attrib: - if 'invisible' not in attrs: - attrs['invisible'] = [] - # This should be done by the server - attrs['invisible'].append(('state', 'not in', elem.attrib['states'].split(','))) - del(elem.attrib['states']) + attrs.setdefault('invisible', [])\ + .append(('state', 'not in', elem.attrib.pop('states').split(','))) if attrs: - elem.attrib['attrs'] = simplejson.dumps(attrs) + elem.set('attrs', simplejson.dumps(attrs)) for a in ['invisible', 'readonly', 'required']: if a in elem.attrib: # In the XML we trust - avalue = bool(eval(elem.attrib.get(a, 'False'), + avalue = bool(eval(elem.get(a, 'False'), {'context': context or {}})) if not avalue: del elem.attrib[a]