I want to hide Duplicate
button located under action
of sale order
. Is there any possible way to hide this button?
I can restrict the users by adding Warning
in python but I want to hide it in xml.
I found the solution.
Inherit sale order form view and then add attribute duplicate='false'
. Following is the code:
<record id="view_order_form_duplicate" model="ir.ui.view">
<field name="name">sale.order.form.duplicate</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//form" position="attributes">
<attribute name="duplicate">false</attribute>
</xpath>
</field>
</record>
You can also add security group if you want to hide it for some specific users.
<record id="view_order_form_duplicate" model="ir.ui.view">
<field name="name">sale.order.form.duplicate</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="groups_id" eval="[(6, 0, [ref('module_name.group_name')])]"/>
<field name="arch" type="xml">
<xpath expr="//form" position="attributes">
<attribute name="duplicate">false</attribute>
</xpath>
</field>
</record>
This code works for me.