Using the form and tree views in openerp one2many list at once
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"/>
&开发者_开发百科lt;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
==============
Form fields
Tree View
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 !
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>
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.
It's just an idea, but maybe this design can solve your issue. If you have an "order" object with many "product lines":
- Create a many2many field on the "product line" linking to itself using a parent_id
- Create a Form for the "product line" object with product_id and product_qty
- Add to the form a Tree list base on the on the many2many field.
Would this do the trick?
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
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.?
精彩评论