我有简单的数据库,有3个模型如下
1-营地(存储营地主数据)
2-玩家(存储玩家主数据)
3- players_camps(每个玩家参加的营地)
所有模型的代码如下:
class Camps(Model):
_name = 'camps'
name = Char('Name')
organizer = Char()
date_from = Date('From date')
date_to = Date('To date')
place = Char()
supervisor = Char()
notes = Text()
class players(Model):
_name = 'player'
name = Char()
camps = One2many('player_camps', 'player')
class player_camps(Model):
_name = 'player_camps'
camps = Many2one('camps', on_delete='CASCADE', on_update='CASCADE')
organizer = Many2one('camps', on_delete='CASCADE', on_update='CASCADE')
place = Many2one('camps', on_delete='CASCADE', on_update='CASCADE')
date_from = Many2one('camps', on_delete='CASCADE', on_update='CASCADE')
date_to = Many2one('camps', on_delete='CASCADE', on_update='CASCADE')
result = Integer(default=0)
当我显示玩家阵营时(在视图中使用One2many小部件)我只能看到阵营名称而是其他数据 像组织者或地方(存储在营地的主模型中)未显示 如何在玩家营地视图的树形视图中显示此数据?
修改:这是播放器的视图文件
注意:我已从玩家视图及其模型中移除了一些字段以缩短代码
<openerp>
<data>
<!--Form view -->
<record id="Player_form_view" model="ir.ui.view">
<field name="model">player</field>
<field name="arch" type="xml">
<form>
<notebook>
<page name="basic_data" string="Basic Data">
<group>
<field name="name"/>
</group>
</page>
<page name="camps" string="Camps">
<field name="camps">
<tree>
<field name="camp"/>
<field name="instructor"/>
<field name="organizer"/>
<field name="place"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="result"/>
<field name="notes"/>
</tree>
</field>
</page>
</notebook>
</form>
</field>
</record>
</data>
</openerp>
答案 0 :(得分:0)
请从one2many列表中删除小部件,并在<tree>
标记声明的字段中删除您想要显示的小部件。
尝试使用以下代码:
<openerp>
<data>
<!--Form view -->
<record id="player_form_view" model="ir.ui.view">
<field name="name">player.form.view</field>
<field name="model">spogaze.player</field>
<field name="arch" type="xml">
<form>
<notebook>
<page name="basic_data" string="Basic Data">
<group>
<field name="name"/>
</group>
</page>
<page name="exams" string="Exams">
<field name="exams">
<tree string="Exam" editable="bottom">
<field name="camp"/>
<field name="instructor"/>
<field name="organizer"/>
<field name="place"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="result"/>
<field name="notes"/>
</tree>
</field>
</page>
</notebook>
</form>
</field>
</record>
</data>
</openerp>