Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
4771 มุมมอง

Hi,

I spend my morning to find out how to disable the Inventory tab from the products form.

If I know how to hide fields and menus, I never did it before for a tab.

Would anyone give me some tips ?

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

You can try this,

<record id="product_in_customer22" model="ir.ui.view">   
   <field name="name">product.template.view</field>
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_only_form_view"/>
   <field name="arch" type="xml">
         <xpath expr="//page[2]" position="attributes">
        <attribute name="invisible">1</attribute>
        </xpath>

  </field>
</record>

Thanks

อวตาร
ละทิ้ง
ผู้เขียน

Thanks. Can you precise how to get the page[2] ?

what ?

just try the same , page[2] is the position of the inventory tab

ผู้เขียน

Nice job, that works :)

Yep! Do watch out with doing [2] though. If you would ever make other inherits and add pages before the second page then [2] would actually remove another page than what is now your second page. ;)

ผู้เขียน

Thanks for that precision Yenthe,

Could you precise how to get the techncial_page_name and avoid this kind of possible future mistake ?

คำตอบที่ดีที่สุด

HI Silvere,

You can simply inherit the view and then make an xpath to remove the tab from the view. An example inherit with an xpath on the tab:

<record id="view_product_template_form_inherit" model="ir.ui.view">

<field name="name">product.template.form.inherit</field> <field name="model">your.model</field> <field name="type">form</field> <field name="inherit_id" ref="module.view_name"/> <field name="arch" type="xml"> <xpath expr="//page[@name='technical_page_name']" position="replace"/> </field> </record>

Regards,
Yenthe

อวตาร
ละทิ้ง
ผู้เขียน

Thanks Yenthe.

Could you precise me how to find the technical_page_name ?

คำตอบที่ดีที่สุด

Hi 

you can use this code Xml 


<record id="view_product_template_form_inherit" model="ir.ui.view">

<field name="name">product.template.form.inherit</field> <field name="model">your.model</field> <field name="type">form</field> <field name="inherit_id" ref="product.product_template_form_view"/> <field name="arch" type="xml"> <xpath expr="//page[@string='inventory']" position="replace"/> </field> </record>


or

<record id="view_product_template_form_inherit" model="ir.ui.view">

<field name="name">product.template.form.inherit</field> <field name="model">your.model</field> <field name="type">form</field> <field name="inherit_id" ref="product.product_template_form_view"/> <field name="arch" type="xml"> <page string=inventory" position="replace"/> </field> </record>

อวตาร
ละทิ้ง
ผู้เขียน

Thanks for that :)

Actually, this wouldn't work at all. Using @string decorators in xpaths has been deprecated in V10 and up so this would give a traceback.

ok thank Yenthe

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 25
600
0
มิ.ย. 24
1909
0
มี.ค. 24
2030
2
ม.ค. 24
2364
1
ก.พ. 25
3558