【odoo15】继承视图并隐藏某个字段,或隐藏notebook中的某个page,更改notebook的page名

继承一下维修模型的视图,对它做一些更改:举个例子,就比如我要隐藏一下这个字段和下面的这个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>
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值