도움말

2

Change the Position of field in Xpath

Avatar
Rajiv

Hi

I want to change the position of Field in the Form View (Parent) to the new Position (In my In herited view). Is there any way.

Example:

Parent View:

<record id="1" model="1">

<field name="arch" type="xml">

<group>

<field name="X"/>

</group>

.....

.....

<group>

<field name="Y"/>

</group>

</field>

</record>

So I want to move the field Y to inside the group X. Not only field. Also I need to move the any other tags like <div> or <group> itself as bunch.

Is there any Xpath which is like below.

<xpath expr="//form/sheet/group/group/field[@name='email']" position="move">

Please help...

 

 

아바타
작성취소
5 응답
0
Avatar
Ajay Kumar
최고의 답변

Hello,

we can one more thing instead of "replace". Because in case of replace first we have to  remove the field and then add it to new position which will take one more step extra. So better we can use position="move"

<xpath expr="//field[@name='phone']" position="after">
<xpath expr="//field[@name='tag_ids']" position="move"/>
</xpath>
it will simply move the position of tag_ids field to after phone field. Which will save our extra line of code that we are writing in case of replace.
아바타
작성취소
6
최고의 답변

Hello,

There is no such value allowed like move in xpath. Values allowed are

  • inside (default): your values will be appended inside the tag

  • after: add the content after the tag

  • before: add the content before the tag

  • replace: replace the content of the tag.

You have to simply replace that field. and put it to new position. For more details, You can refer Doc or can ask me too.

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

This will remove field from that position. Now you can put it to other place you want. Suppose you want to place it after field "Y". Example -

<xpath expr="//group/field[@name='Y']" position="after">
<field name="X"/>
</xpath>

This way, You can change postion of any field, group etc.

Hope this will help you.

2 의견
아바타
작성취소

Hello @Mansi, I want to add new boolean filed after supplier boolean field in res.partner form inside sale & purchase tab. Can you help me.! Thanks in advance.

Avatar
Mansi Kariya (mka)
-

Inherit view_partner_form and then givve xpath like //page[@string='Sales & Purchases']/group/group/field[@name='supplier'] and give position to after

1
Avatar
William Brugger
최고의 답변

Move has been added to xpath:

https://github.com/odoo/odoo/pull/23877

아바타
작성취소
1
Avatar
legland
최고의 답변

I have the same issue, the view field is not visible.

'data': [

        'views/stock_production_lot_views.xml',

        # 'security/ir.model.access.csv',


    ],

https://www.odoo.com/fr_FR/forum/aide-1/question/odoo-v12-xpath-not-visible-145057


아바타
작성취소
1
Avatar
Baiju KS
최고의 답변

Hi Rajiv,,

Here you can use position=replace

you can select the code or block you want to replace

아바타
작성취소