Files
gzth/yuthon_performance/models/yuthon_Index_management.py
T
2024-11-30 19:43:00 +08:00

81 lines
3.8 KiB
Python

from odoo import models, fields, api, exceptions, _
class YuthonIndexManagement(models.Model):
_name = 'yuthon.index.management'
_description = "组织绩效标准库"
_rec_name = 'index_name'
sequence = fields.Char(string='序号', store=True)
dimension = fields.Char('维度')
development_goals = fields.Char('发展目标')
index_name = fields.Char('指标名称')
index_definition = fields.Text('指标定义')
index_type = fields.Selection([('kpi', 'KPI'),
('gs', 'GS'), ('no', '否决指标')],'指标类别')
index_compute = fields.Text('指标计算公式')
compute_type = fields.Selection([('bad_index', '反向指标'),
('good_index', '正向指标'),
('two_index', '双向指标'),],'计算类别')
check_norm = fields.Text('考核标准')
yuthon_company = fields.Selection([('thtz', '集团本部'), ('thwg', '天河物管'),
('thlc', '天河粮储')], string="所属公司")
department_ids = fields.Many2many("hr.department", string="指标来源")
in_charge_role_id = fields.Many2one('soong.user.role', string='角色', domain=[('user_type', '!=', 'lv_role')])
employee_ids = fields.Many2many('hr.employee', string='人员范围')
start_index_time = fields.Date(string='生效时间', default=fields.Date.today())
end_index_time = fields.Date(string='失效时间')
unit_compute = fields.Char('计算单位')
weight = fields.Char(string="权重%")
compute_method = fields.Char(string="计算方法")
compute_act = fields.Char(string="计划安排及具体措施/行动")
change_index_library_id = fields.Many2one("yuthon.index.approval", string="指标库变更明细")
index_duty_id = fields.Many2one('yuthon.duty.management', string="绩效明细")
index_duty_approval_id = fields.Many2one('yuthon.duty.approval', string="部门责任变更明细")
def put_adjustment_approval(self):
index_applicant_ids = self.env["yuthon.index.management"].browse(self._context.get('active_ids', self._context.get('active_id')))
index_applicant_data = [(6, 0,index_applicant_ids.ids)]
form_id = self.env.ref('yuthon_performance.yuthon_index_approval_form').id
return {
'name': '指标库变更明细',
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'yuthon.index.approval',
'views': [(form_id, 'form')],
'context': {'default_change_index_library_ids': index_applicant_data,}
}
def open_record(self):
return {
"type": "ir.actions.act_window",
"res_model": 'yuthon.index.management',
"res_id": self.id,
"name":"组织库详情",
"view_mode": "form",
}
def put_assessment_tasks_approval(self):
index_applicant_kpi = []
index_applicant_gs = []
index_applicant_ids = self.env["yuthon.index.management"].browse(self._context.get('active_ids', self._context.get('active_id')))
for record in index_applicant_ids:
if record.index_type == "kpi":
index_applicant_kpi.append((0, 0,{
'duty_index_name':record.id,
}))
else:
index_applicant_gs.append((0, 0,{
'work_task':record.development_goals,
}))
return {
'name': '评估任务审批',
'type': 'ir.actions.act_window',
'res_model': 'yuthon.duty.management',
'view_mode': 'form',
'context': {
'default_performance_kpi_ids': index_applicant_kpi,
'default_performance_gs_ids': index_applicant_gs,
}}