From c538db258abdcaa25ff1442c9b4cd3f2bbdb9935 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 14:57:48 +0200 Subject: [PATCH] [IMP] now uses py.eval for options bzr revid: nicolas.vanhoren@openerp.com-20121011125748-8au3gmss2436h5lw --- addons/web/static/src/js/corelib.js | 4 ++++ addons/web/static/src/js/view_form.js | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index b5fbacc7927..8c38724b1d5 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -1440,6 +1440,10 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ }, }); +instance.web.py_eval = function(expr, context) { + return py.eval(expr, _.extend({}, context || {}, {"true": true, "false": false, "null": null})); +}; + } // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index afb5e258c0b..97ad0f220e6 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2087,11 +2087,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w this.field = this.field_manager.get_field_desc(this.name); this.widget = this.node.attrs.widget; this.string = this.node.attrs.string || this.field.string || this.name; - try { - this.options = JSON.parse(this.node.attrs.options || '{}'); - } catch (e) { - throw new Error(_.str.sprintf(_t("Widget options for field '%s' are not valid JSON."), this.name)); - } + this.options = instance.web.py_eval(this.node.attrs.options || '{}'); this.set({'value': false}); this.on("change:value", this, function() {