继承一下维修模型的视图,对它做一些更改:举个例子,就比如我要隐藏一下这个字段和下面的这个page【作业】
只需要继承,然后直接使用xpath语句来隐藏:
<field name="arch" type="xml">
<data>
<xpath expr="//notebook/page[@name='operations']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='description']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</data>
</field>
这就行了,上边的是隐藏notebook/page的name为【operations】,隐藏字段为【description】。追加属性 position="attributes"然后让隐藏 invisible = 1 也就是True改为0就是False。
继承页面完整代码:【 <attribute name="invisible">0</attribute> 】 把隐藏的显示出来
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_approve_repair_order_form" model="ir.ui.view">
<field name="name">approve_repair_order_form</field>
<field name="model">repair.order</field>
<field name="inherit_id" ref="repair.view_repair_order_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//notebook/page[@name='operations']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='description']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</data>
</field>
</record>
</data>
</odoo>
还有一种方式我没尝试过,看一个朋友写的代码:
<!--隐藏 可选产品 页面-->
<xpath expr="//page[@name='optional_products']" position="replace">
</xpath>
<!--隐藏 页面-->
<xpath expr="//page[@name='customer_signature']" position="replace">
</xpath>
<!--修改 销售员 为 业务员-->
<xpath expr="//field[@name='user_id']" position="attributes">
<attribute name="string">业务员</attribute>
</xpath>
就是让xpath里边留空, position="replace"为一个替换的写法,但是替换的东西为空的,就相当于删掉了,把这个东西隐藏了,最下面那个为正常替换。
隐藏 Repair Notes这个page,你会发现这个page没有name:
可以使用索引的方式隐藏:
<xpath expr="//notebook/page[4]" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
更改notebook的page名name值:
<!--修改 作业 为 返修商品 operations-->
<xpath expr="//notebook/page[@name='operations']" position="attributes">
<attribute name="string">返修商品</attribute>
</xpath>