2017-12-13 14 views
0

작업 템플릿 양식에서 group_id를 추가 할 수 있습니다. 내가 속한 그룹에 따라 작업 템플릿을 추가 할 도메인을 만들고 싶지만 현재는 단서가 없습니다.다른 필드를 기반으로 한 필드 on

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> 

답변

1

먼저 모델에서 'project.task.group' 'project.task의 관점에서'project.task '

task_template_id = field.Many2one('project.task.template') 
group_id=field.Many2one('project.task.group') 

template_id = fields.One2many('project.task.template', 'group_id', string='Group 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 to task_template_id로 지정