Reputation: 2397
I have a small question. A module which I am working at the moment requires that I insert a set of fields and a tree view which gets updated when data is entered to the form.
<field name="lines" widget="one2many_list" colspan="4" nolabel="1">
<tree>
<field name="product_id"/>
<field name="product_qty"/>
</tree>
<form>
<field name="product_id"/>
<field name="product_qty"/>
</form>
</field>
The above is a snippet from my view, is it possible to render the form view of the above and the tree view at one in the same page.
For an instance
==============
So that without having to click the new record icon i can add records to the tree view and save them from the form which is displayed above.
Please advise.
Thanks !
Upvotes: 3
Views: 12331
Reputation: 319
You can use this structure for your requirement.
<field name='selected_tea_workers_line_ids' nolabel='1'>
<tree string='List' readonly='1'>
<field name='tea_line_worker_id' invisible="0" />
<field name='worker_id' />
<field name='is_selected' />
</tree>
</field>
but anyone knows how to code for set values for that child fields.?
Upvotes: 1
Reputation: 200
Firstly you will create the field one2many in the parent form field like:
class parent_temp(osv.osv)
_name='parent.temp'
_columns={
'name' : fields.char('Parent Note',size=32),
'temp_ids' : fields.one2many('temp.check', 'temp_id','temp note'),
}
class temp_check(osv.osv)
_name='temp.check
_columns={
'name':fields.char('temp',size=32),
'temp_id':fields.many2one('parent.temp','temp note'),
}
Ok, it is py declaration, now we will create view for one2many field with tree update:
#form view
<form string="Temp Notes">
<field name='name'/> #parent field
<field colspan="4" name="temp_ids" nolabel="1">
<tree string="Notes" editable="top">
"""
write field here which u want to show in tree view
"""
<field name='name'/> #child field
</tree>
</field>
</form>
#here editable option top or bottom
Upvotes: 1
Reputation: 5044
In tree view there is an attribute called 'editable'. You can use editable='top' or editable='bottom'
<field name="lines" widget="one2many_list" colspan="4" nolabel="1">
<tree editable='bottom'>
<field name="product_id"/>
<field name="product_qty"/>
</tree>
<form>
<field name="product_id"/>
<field name="product_qty"/>
</form>
</field>
Upvotes: 4
Reputation: 56620
I think you're asking if there's a way to add or edit records in a tree view without having to pop open a window for each record.
Some views do have tree views that can be edited in place. One example that I can think of is the supplier price list on the Product screen. Another is Entries Encoding by Move in the Accounting section. If you look at the source code, you can probably figure out how they do it.
Upvotes: 3
Reputation: 13342
It's just an idea, but maybe this design can solve your issue. If you have an "order" object with many "product lines":
Would this do the trick?
Upvotes: 1