【发布时间】:2015-09-23 08:28:17
【问题描述】:
我正在尝试隐藏 Odoo 中物料清单表单中的编辑按钮,具体取决于布尔值的状态。
我设法使用以下代码永久删除了编辑按钮:
<xpath expr="//form[@string='Bill of Material']" position="attributes">
<attribute name="edit">false</attribute>
</xpath>
现在我尝试使用这样的布尔值使其成为条件:
<xpath expr="//form[@string='Bill of Material']" position="attributes">
<attribute name="edit">true:realman==True;false:realman==False;</attribute>
</xpath>
这给出了错误:
SyntaxError: JSON.parse: 意外的非空白字符后 JSON 数据第 1 行第 5 列的 JSON 数据
当我查看 javascript 文件时,我发现这是处理编辑属性的代码:
/**
* Return whether the user can perform the action ('create', 'edit', 'delete') in this view.
* An action is disabled by setting the corresponding attribute in the view's main element,
* like: <form string="" create="false" edit="false" delete="false">
*/
is_action_enabled: function(action) {
var attrs = this.fields_view.arch.attrs;
return (action in attrs) ? JSON.parse(attrs[action]) : true;
},
当我的表单中的布尔值realman 是False 时,我想我需要在var attrs 中获得false?
我已经尝试将它写在大括号中,就像这个问题的答案一样:JSON.parse unexpected character error
这也给了我错误。
为什么会出现此错误,我该如何解决?这只是语法错误还是有更多问题?
【问题讨论】:
标签: javascript json xml xpath openerp