我是odoo9中的新手,如何用两个表创建简单模块的任何示例。 第一桌等队(teamId,teamName,teamDescription)和第二桌玩家(playerId,teamId,playerName,playerSurname)。
在下面的列表中添加团队后,我需要为该团队添加玩家
示例https://postimg.org/image/uam0v0cct/
class team_module(model.Models):
_name = 'team.module'
_description = 'team description'
name = fields.char('Team Name', size=128, required=True)
description = fields.char('Team desc', size=256)
class player_module(model.Models):
_name = 'player.module'
_description = 'player description'
name = fields.char('Player Name', size=128, required=True)
surname = fields.char('Player Surname', size=128, required=True)
任何简单的解决方案或模块?
答案 0 :(得分:0)
使用One2many
中的team_module
字段:
player_ids = fields.One2many('player.module', 'player_id', string='Players')
然后将player_id
添加到player_module
:
player_id = fields.Many2one('team.module', string='Team Reference',
ondelete='cascade', index=True)