自定义模块覆盖默认视图?

slu*_*c23 5 openerp

有没有办法覆盖openerp的默认视图,开发模块而不是手动从Settings/Customization/User Interface/Views ...?

我们正在使用OpenERP并自定义许多默认视图(项目列表,发票清单,发票搜索等),从列表和搜索过滤器/组中添加和隐藏字段,我们正在通过Web客户端的视图手动查看.有没有办法开发一个模块,我可以为我想要自定义的所有视图编写xml,当我安装该模块时,所有视图(以及窗口操作)都将更新?

Moh*_*ash 6

您可以使用" 视图继承"来使用XML文件自定义任何视图.

使用继承,您可以向任何视图添加,删除和替换元素.您还可以定义新的完整视图以替换默认值而不是继承.只需使用XML文件创建一个新模块,该文件可自定义或替换当前视图并加载该模块.该模块的文件夹应该只包含__init__.py,__openerp__.py以及XML文件.

以下是EAN13从产品视图中删除字段的简单示例.


__init__.py 空的文件


__openerp__.py:

{
    "name" : "View Customization Test",
    "version" : "1.0",
    "category" : "Generic Modules/Inventory Control",
    'depends' : ['product',],
    "update_xml" : ["product.xml",],
    "installable": True,
    "active": True
}
Run Code Online (Sandbox Code Playgroud)

product.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="view_product_form_custom">
      <field name="name">product.form.inherit2</field>
      <field name="model">product.product</field>
      <field name="inherit_id" ref="product.product_normal_form_view" />
      <field name="arch" type="xml">
        <field name="ean13" position="replace" />
      </field>
    </record>
  </data>
</openerp>
Run Code Online (Sandbox Code Playgroud)