我正在尝试进行部门明智的项目阶段。默认情况下,任务阶段是根据项目生成的。
我这样做是为了为部门和阶段添加Many2many关系。
class DepartmentStages(models.Model):
_inherit = 'project.task.type'
department_ids = fields.Many2many(comodel_name='hr.department',
relation='hr_department_project_task_type_rel',
column1='project_task_type_id',
column2='hr_department_id', string='Departments')
此外,我在stages_ids
中添加了hr.department
。
class HrDepartmentInherit(models.Model):
_inherit = 'hr.department'
stage_ids = fields.Many2many(comodel_name='project.task.type',
relation='hr_department_project_task_type_rel',
column1='hr_department_id',
column2='project_task_type_id',
string='Tasks Stages')
我在department_id
中添加了project.project
字段。
class ProjectProjectInhert(models.Model):
_inherit = 'project.project'
department_id = fields.Many2one(
comodel_name='hr.department',
default=_get_department,
string='Department')
@api.multi
def _get_department(self):
emp_model = self.env['hr.employee']
department_id = False
employee = emp_model.search([('user_id', '=', self.env.uid)], limit=1)
if employee and employee.department_id:
department_id = employee.department_id.id
return department_id
要在stage_id
中获得project.task
,我已经继承了如下字段:
class ProjectTaskInherit(models.Model):
_inherit = 'project.task'
stage_id = fields.Many2one(comodel_name='project.task.type', string='Stage',
track_visibility='onchange', domain="[('department_ids', '=', project_id.department_id)]")
这显示Uncaught Error: AttributeError: object has no attribute 'department_id'
。
那么,我该如何应用域过滤器以使部门部门明智? 预先谢谢你。