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

Hi,

In my base module, i have few fields defined in a group and i want to add a custom field in that group with the other fields. Currently i'm replacing the entire group because if i just add my custom field in between other fields using xpath, it is ruining the view of other fields. I just want to know is there any better way to do it than having to replace the entire group for just one field?

Base module code:

<field name="function" placeholder="e.g. Sales Director"
attrs="{'invisible': [('is_company','=', True)]}"/>
<field name="phone" widget="phone"/>
<field name="mobile" widget="phone"/>
<field name="user_ids" invisible="1"/>
<field name="email" widget="email" context="{'gravatar_image': True}"
attrs="{'required': [('user_ids','!=', [])]}"/>
<field name="website" widget="url" placeholder="e.g. www.odoo.com"/>
<field name="title" options='{"no_open": True}'
attrs="{'invisible': [('is_company', '=', True)]}"/>
<field name="lang"/>
<field name="category_id" widget="many2many_tags"
options="{'color_field': 'color', 'no_create_edit': True}" placeholder="Tags..."/>

Inherited module code:

<xpath expr="//form/sheet/group[1]/group[2]" position="replace">
<group>
<field name="function" placeholder="e.g. Sales Director"
attrs="{'invisible': [('is_company','=', True)]}"/>
<field name="phone" widget="phone"/>
<field name="mobile" widget="phone"/>
<field name="fax" widget="phone"/>
<field name="user_ids" invisible="1"/>
<field name="email" widget="email" context="{'gravatar_image': True}"
attrs="{'required': [('user_ids','!=', [])]}"/>
<field name="website" widget="url" placeholder="e.g. www.odoo.com"/>
<field name="title" options='{"no_open": True}'
attrs="{'invisible': [('is_company', '=', True)]}"/>
<field name="lang"/>
<field name="category_id" widget="many2many_tags"
options="{'color_field': 'color', 'no_create_edit': True}" placeholder="Tags..."/>
</group>
</xpath>

Thanks

P.S: I want to add fax field after the field mobile and keep the rest of the fields as it is in base module.

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

Inherit and simply add

position='after'

<field name="mobile" position="after">
    <field name="fax"/>
</field>
อวตาร
ละทิ้ง
ผู้เขียน

That is ruining the view of other fields i.e., my field fax gets displayed after a tab space of the field mobile

ผู้เขียน

It won't even display the added field sometimes.

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

<xpath expr="//field[@name='user_ids']" position="replace">

<field name="fax"/>

</xpath>

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

<xpath expr="//field[@name='mobile']" position="after">

<field name="fax" />

</xpath>

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Help with XPath and View Inheritance แก้ไขแล้ว
4
ส.ค. 21
67018
3
เม.ย. 19
6685
Why won't this xpath work? แก้ไขแล้ว
1
เม.ย. 19
5575
1
มี.ค. 19
10514
0
ธ.ค. 23
45