在 Odoo 中禁用或隐藏保存按钮

Disable or hide save button in Odoo

我试图在 Odoo v8 中隐藏表单顶部的保存按钮。或者我需要覆盖保存按钮。

我试过 write = "false"。我在表单视图上的代码:

<record id="plan_settlement_contract_view_form" 
model="ir.ui.view">
<field name="name">plan.settlement.contract.view.form</field>
<field name="model">plan.settlement</field>
<field name="arch" type="xml">
<form string="Settlement Contract"  write='false'>
</form>

这是我现在拥有的:

这就是我需要的:

您无需覆盖任何内容,但必须配置业务对象的访问权限。在这种情况下,您必须更改特定访问组的 "write" 访问权限或什至更多(创建、取消链接)。

首先要阅读的应该是 the official documentation。链接的是针对 Odoo V12 的,但是访问控制自版本 7 以来并没有太大变化,所以对您来说应该没问题。

您应该从模型访问权限开始,因为记录规则有点复杂:

Managed by the ir.model.access records, defines access to a whole model.

Each access control has a model to which it grants permissions, the permissions it grants and optionally a group.

Access controls are additive, for a given model a user has access all permissions granted to any of its groups: if the user belongs to one group which allows writing and another which allows deleting, they can both write and delete.

If no group is specified, the access control applies to all users, otherwise it only applies to the members of the given group.

Available permissions are creation (perm_create), searching and reading (perm_read), updating existing records (perm_write) and deleting existing records (perm_unlink)

您会在名为 ir.model.access.csv 的 .csv 文件中或在 Settings/Security/Access Controls List 下的 Odoo 本身中找到每个 module/app 中的最多访问权限。从版本 9 开始,您必须激活开发者模式才能看到该菜单。

Edit/Save 按钮不会显示给没有写入权限的用户。没有创建权限,创建按钮不会显示。如果没有取消链接权限,删除操作不应该存在。等等。

主题太复杂,无法解释此答案的所有内容。