2017-12-13 6 views
0

タスクテンプレートフォームでは、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> 

答えて

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をtask_template_idに設定します

関連する問題