首先激活Odoo 开发者模式,这样你就可以轻松获取任何对象的外部 id。
激活 Odoo 开发者模式 https://stackoverflow.com/questions/32836304/how-to-activate-openerp-developer-mode/32836764#32836764
如何知道任何对象的外部ID
打开该表单,仅当满足以下条件时,您才能在页面顶部看到一个下拉字段:开发者模式活跃。
然后从下拉列表中选择“编辑表单视图”选项,您可以看到该表单视图的详细信息,例如模型名称、该视图的外部 ID 等等。
In your case to inherit this form use "account.invoice_supplier_form" external id of this form, see this image.
要知道外部 ID of 菜单项,
转到设置 => 技术 => 用户界面 => 菜单项
Search menu name that you want, open that record and select View Metadata from the debug mode drop down.
如何隐藏菜单项:
要隐藏菜单项,一种最简单的方法是创建新组(其中只有指定的用户可以访问)并在重新定义该菜单时将该组分配给菜单项。
使用 xml 文件创建一个组,必须首先将其添加到__openerp__.py.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="new_group_id" model="res.groups">
<field name="name">New Group Name</field>
<field name="category_id" ref="base.module_category_hidden"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>
并创建另一个 xml 文件,在其中使用该 xml 代码更新该菜单项。
<record id="account.menu_action_tax_code_tree" model="ir.ui.menu">
<field name="groups_id" eval="[(6, 0, [ref('new_group_id')] )]"/>
</record>
另一种方法是从 UI 执行此操作,直接将新创建的组分配给菜单项转到设置 => 技术 => 用户界面 => 菜单项(它是回滚,而模块将升级,其中该菜单项定义)。
如何隐藏现有视图中的字段
要隐藏/添加现有表单中的任何字段,您必须首先继承该视图并使用 xpath 或直接字段找到该字段并分配属性以隐藏该字段。
Example:
<record id="new_id" model="ir.ui.view">
<field name="name">New.name</field>
<field name="inherit_id" ref="account.invoice_supplier_form" />
<field name="model">account.invoice</field>
<field name="arch" type="xml">
<data>
<!-- path according to the fields that you want to hide from tree -->
<xpath expr="/form/sheet/notebook/page/field[@name='line_cr_ids']/tree/field[@name='account_id']" position="attributes">
<attribute name="invisible">True/1</attribute>
</xpath>
<field name="tax_line" position="attributes">
<attribute name="invisible">True/1</attribute>
</field>
</data>
</field>
</record>