在任务模板表单中,我可以添加group_id。我想创建一个域,根据它们所属的组添加任务模板但是现在还没有任何线索。
class ProjectTaskGroup(models.Model):
_name = 'project.task.group'
_inherit = 'project.object'
name = fields.Char(string="Name", required=True)
class ProjectTaskTemplate(models.Model):
_name = 'project.task.template'
_inherit = 'project.object'
name = fields.Char(string="Name", required=True)
group_id = fields.Many2one('project.task.group', string="Task Group")
<!-- Project Task Views -->
<record id="view_task_form2" model="ir.ui.view">
<field name="name">project.task.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field name="arch" type="xml">
<xpath expr="//div[@class='oe_title']" position="before">
<div class="oe_inline oe_edit_only">
<field name="group_id" class="oe_inline"/>
<field name="task_template_id" class="oe_inline"/>
</div>
</xpath>
</field>
</record>
答案 0 :(得分:1)
首先在模型'project.task.group'中添加字段
template_id = fields.One2many('project.task.template', 'group_id', string='Group task')
'project.task'字段
task_template_id = field.Many2one('project.task.template')
group_id=field.Many2one('project.task.group')
鉴于'project.task'
<field name="task_template_id" class="oe_inline"/>
<field name="group_id" class="oe_inline" domain="[('template_id', '=', task_template_id)]"/>
首先选择模板,这样我们就可以将group_id belogs带到task_template_id