This question has been flagged
4 Replies
4346 Views

I want to add a field 'cost' inside the one2many firld bom_line_ids

When I try to access the fields inside, I get an error 'too many fields to unpack'

How to do this? This is my code:


<field name="inherit_id" ref="mrp.bom.form"/>

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

<page string="Components">

<field name="bom_line_ids" widget="one2many_list">

<tree string="Components" editable="bottom">

<field name="sequence" position="after">

<field name="cost"/>

Avatar
Discard
Best Answer

Arjun Khode,

1) Make sure you have added that field from python for the one2many model.

2) Make sure model name is mrp.bom

3) Provide fully qualified path to get exact position.

Here you go!

     <record id="inherit_mrp_bom_form_view" model="ir.ui.view">

     <field name="name">inherit.mrp.bom.form</field>

     <field name="model">mrp.bom</field>

     <field name="inherit_id" ref="mrp.bom.form"/>

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

         <xpath expr="//notebook/page[@string='Components']/field[@name='bom_line_ids']/tree[@string='Components']/field[@name='sequence']" position="after">

             <field name="cost" />

        </xpath>

        </field>

    </record>

......

Hope this will helps you.

Regards,

Anil.

Avatar
Discard
Best Answer

why you've set attribute position="after" with the field "sequence" ? you don't have to set it.

Avatar
Discard

You removed

position="after"
from sequence tag?
Author

yes, I tried removing it Temur. It didn't work

ok. keep it removed, you're using tree inside of one2many tag.. in this case you have to add all fields you like to be displayed to this tree, but you don't need to use "position" atribute, just write fields in order that you like. can you post bit more lines of xml record?

Best Answer

try using xpath to inherit existing view

<xpath expr="//page[@string='Components']/field[@name='bom_line_ids']/tree[@string='Components']/field[@name='sequence']" position="after">
    <field name="cost" />
</xpath
Avatar
Discard
Author

It's still giving me "too many fields to unpack error"