from odoo import models, fields, api, exceptions, _ class YuthonIndexManagement(models.Model): _name = 'yuthon.index.management' _description = "组织绩效标准库" name = fields.Char('指标库', required=True) dimension = fields.Char('维度', required=True) development_goals = fields.Char('发展目标', required=True) index_name = fields.Char('指标名称', required=True) index_definition = fields.Text('指标定义', required=True) index_type = fields.Selection([('kpi', 'KPI'), ('gs', 'GS'), ('refused_index', '否决指标'),],'指标类别') index_compute = fields.Char('指标计算公式', required=True) compute_type = fields.Selection([('bad_index', '反向指标'), ('good_index', '正向指标'), ('two_index', '双向指标'),],'计算类别') check_norm = fields.Char('考核标准', required=True) department_ids = fields.Many2many("hr.department", string="指标来源", required=True) in_charge_role_ids = fields.Many2many('soong.user.role', string='角色') employee_id = fields.Many2one('hr.employee', string="人员") start_index_time = fields.Date(string='生效时间', required=True) 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): pass