我有一个小问题。我目前正在工作的一个模块要求我插入一组字段和一个树形视图,当数据输入到表单时会更新。
<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>
上面是我看来的一个片段,是否可以在同一页面中将上面的表单视图和树视图呈现在一个。
对于实例
==============
因此,无需单击新记录图标,我就可以将记录添加到树视图中,并将其保存在上面显示的表单中。
请告知。
谢谢!
答案 0 :(得分:4)
在树状视图中,有一个名为“可编辑”的属性。您可以使用editable ='top'或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>
答案 1 :(得分:3)
我认为您在询问是否有办法在树状视图中添加或编辑记录,而无需为每条记录弹出一个窗口。
某些视图的树视图可以在适当的位置进行编辑。我能想到的一个例子是产品屏幕上的供应商价格表。另一个是“会计”部分中的“按移动编码”条目。如果你看一下源代码,你可能会弄清楚它们是如何做到的。
答案 2 :(得分:1)
这只是一个想法,但也许这个设计可以解决你的问题。 如果您有一个包含许多“产品系列”的“订单”对象:
这可以解决这个问题吗?
答案 3 :(得分:1)
首先,您将在父表单字段中创建字段one2many,如:
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'),
}
好的,它是py声明,现在我们将使用树更新为one2many字段创建视图:
#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
答案 4 :(得分:1)
您可以根据需要使用此结构。
<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>
但是,任何人都知道如何为该子字段的设置值进行编码。?