qWeb 条件不适用于FormView
.
您可以在这里查看(path_to_odoo/addons/web/static/src/js/framework/view.js):
/**
* 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;
},
该方法从模板中调用FormView.buttons
in path_to_odoo/addons/web/static/src/xml/base.xml:
<button t-if="widget.is_action_enabled('edit')"
type="button"
class="oe_form_button_edit btn btn-default btn-sm" accesskey="E">
Edit
</button>
这些问题在 Odoo 中借助规则得到了解决(ir.rule
Odoo 的对象)
您可以在 GUI 中查找和编辑规则:设置(顶部菜单)-> 安全性(左侧菜单)-> 访问规则(左侧菜单)。使用管理员用户处于调试模式为了这。
同时你可以添加一些规则data.xml
您的模块的导入。它们将在您安装或更新模块时添加。
当心!记录规则不适用于管理员用户 https://www.odoo.com/documentation/9.0/reference/security.html#record-rules.
同时您可以尝试扩展小部件FormView
.
希望这对您有帮助。