2

I tried this code but nothing happened:

#view.xml

<odoo>
 <data>

  <record id="view_pos_config_kanban_inherit" model="ir.ui.view">
    <field name="name">pos.config.inherit</field>
    <field name="model">pos.config</field>
    <field name="inherit_id" ref="point_of_sale.view_pos_config_kanban"/>
    <field name="arch" type="xml">
     <xpath expr="//kanban/templates/t/div/div[3][contains(@class='o_kanban_manage_button_section')]" position="replace">
     </xpath>
    </field>
  </record>

 </data>
</odoo>

What I want To Hide

jahmia
  • 65
  • 1
  • 10

2 Answers2

1

Odoo will raise odoo.tools.convert.ParseError: "Invalid number of arguments" because of contains function used in div.

You can check in the XPath documentation provided by Odoo that contains is a function to manipulate strings:

contains(s1, s2)
    returns true if s1 contains s2

Use XPath to locate the div with o_kanban_manage_button_section class and make it invisible.

Example:

<record id="view_pos_config_kanban" model="ir.ui.view">
    <field name="name">pos.config.kanban.view</field>
    <field name="model">pos.config</field>
    <field name="inherit_id" ref="point_of_sale.view_pos_config_kanban"/>
    <field name="arch" type="xml">
        <xpath expr="//t/div/div/div[@class='o_kanban_manage_button_section']" position="attributes">
            <attribute name="invisible">True</attribute>
        </xpath>
    </field>
</record>  
Kenly
  • 24,317
  • 7
  • 44
  • 60
1

My Solution:

<odoo>
    <data>
        <record id="view_pos_config_kanban" model="ir.ui.view">
            <field name="name">pos.config.kanban.view</field>
            <field name="model">pos.config</field>
            <field name="inherit_id" ref="point_of_sale.view_pos_config_kanban"/>
            <field name="arch" type="xml">
                <xpath expr="//kanban/templates/t/div/div[1]/div[2][@class='o_kanban_manage_button_section']" position="replace">
                </xpath>
            </field>
        </record>
    </data>
</odoo>
  • This kind of XPATH is very risky It will break by other xpath that addes div, when I target a div that don't have a name or a special class I target a special child inside then go up to it, `//field[@name='dummy']/parent::div` and you can keep going up as much as you want as i remember, bottom line avoid using index of element as much as possible – Charif DZ Aug 14 '20 at 15:40
  • And onething more dont use `@class='value'` instead use `hasclass('value')` because class can change a lot especially in website templates by other modules – Charif DZ Aug 14 '20 at 15:43