2
votes

In Odoo 9, I want to put a core field in a different page from the original.
Inside Inventory -> Product, the field is categ_id:

Original page = "Inventory"
Wanted page = "General Information"

I have this code:

<record id="product_template_only_form_view_extend" model="ir.ui.view">
    <field name="name">product.template.product.form</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="//field[@name='categ_id']" position="attributes">
            <attribute name="invisible">1</attribute>
        </xpath>
        <xpath expr="//field[@name='default_code']" position="after">
            <field name="categ_id" string="Internal Category"/>
        </xpath>
    </field>
</record>

With the first xpath, I set invisible the field of Original page. That works.

With the second xpath, I show the categ_id field in the Wanted page. That works too, but the value is not modified in product_template model when I modify the value and press the save button.

Did I miss something?

1

1 Answers

1
votes

You cannot have a duplicated field on one form. So you need to remove it first from the first place, invisible is not enough. Take a look at this:

<record id="product_template_only_form_view_extend" model="ir.ui.view">
    <field name="name">product.template.product.form</field>
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_only_form_view"/>
    <field name="arch" type="xml">
        <field name="categ_id" position="replace" />

        <field name="default_code" position="after">
            <field name="categ_id" string="Internal Category"/>
        </field>
    </field>
</record>