user2379186
user2379186

Reputation: 431

Change the Position of field - Odoo

I am using Odoo 10 and I am trying to move the position of the mobile field. The below code works but the new mobile field does not have any data. Mobile number is missing. I remove that code and the mobile number comes back.

<xpath expr="//field[@name='mobile']" position="attributes">
               <attribute name="invisible">1</attribute>
            </xpath>
            <xpath expr="//field[@name='category_id']" position="after">
                <field name="mobile" />
            </xpath> 

Upvotes: 1

Views: 1168

Answers (2)

Max
Max

Reputation: 529

Veikko`s answer is universal for all versions of Odoo but requires to rewrite full dom structure in new place

For Odoo starting version 12.0 best for move field and other is (described here):

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

Upvotes: 0

Veikko
Veikko

Reputation: 3610

You cannot have same field twice in the view. You need to completely remove the field first and add it to another place after that. Your templates work if you change the first xpath to remove the field, not just hide it. This can be done like this

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

Upvotes: 1

Related Questions