【发布时间】:2015-05-04 10:32:36
【问题描述】:
让我们从一个基本的 One2many 关系开始,一个类 Parent 和一个类 Child。
型号:
class Parent(models.Model):
_name = 'module.parent'
child_ids = fields.One2many('module.child', 'parent_id')
class Child(models.Model):
_name = 'module.child'
parent_id = fields.Many2one('module.parent')
观看次数:
<record model="ir.ui.view" id="parent_form_view">
<field name="name">parent.form</field>
<field name="model">module.parent</field>
<field name="arch" type="xml">
<form string="Parent Form">
<sheet>
<field name="child_ids" />
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="child_form_view">
<field name="name">child.form</field>
<field name="model">module.child</field>
<field name="arch" type="xml">
<form string="Child Form">
<sheet>
<field name="parent_id" />
</sheet>
</form>
</field>
</record>
当我打开一个 Parent 表单并尝试从 one2many 弹出窗口创建一个新的 Child 时,parent_id 字段未选择当前打开的 父 从窗口视图!
我必须在parent_id 选择字段中检索它才能重新选择它。
有没有办法进行这种自动选择?
【问题讨论】:
标签: python openerp odoo many-to-one openerp-8