From c8887fd2f92d10ba5c202668f37cbefd89c88c1c Mon Sep 17 00:00:00 2001 From: Cristian Salamea Date: Tue, 11 Aug 2015 10:42:13 -0500 Subject: [PATCH] FIX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit testing in all cases is better catch errno in JSON.parse. attrs[action] is always “string” type. --- web_action_conditionable/static/src/js/views.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web_action_conditionable/static/src/js/views.js b/web_action_conditionable/static/src/js/views.js index 9daf279c..c9713913 100644 --- a/web_action_conditionable/static/src/js/views.js +++ b/web_action_conditionable/static/src/js/views.js @@ -5,9 +5,10 @@ openerp.web_action_conditionable = function (instance) { is_action_enabled: function(action) { var attrs = this.fields_view.arch.attrs; if (action in attrs) { - if ($.type(attrs[action]) == 'boolean') { - return JSON.parse(attrs[action]) - } else { + try { + data = JSON.parse(attrs[action]); + return data; + } catch(error) { var expr = attrs[action]; var expression = py.parse(py.tokenize(expr)); var cxt = this.dataset.get_context().__eval_context.__contexts[1];