diff --git a/yuthon_hr_attendance/models/holidays_approval.py b/yuthon_hr_attendance/models/holidays_approval.py index ceefd43bc..07b36fbd5 100644 --- a/yuthon_hr_attendance/models/holidays_approval.py +++ b/yuthon_hr_attendance/models/holidays_approval.py @@ -35,8 +35,7 @@ class HolidaysApprovalsLine(models.Model): name = fields.Char(string="请假事由") approvals_id = fields.Many2one('holidays.approval', string="管理请假审批") vacation_category = fields.Many2one('holiday.type.setting', string="休假类别") - leave_type_id = fields.Many2one('hr.leave.type', string="请假类型", - domain="[('vacation_type_id', '=', vacation_category)]") + leave_type_id = fields.Many2one('hr.leave.type', string="请假类型",) days_available = fields.Float(string="可用天数", store=True) applicants = fields.Selection([('hour', '按小时'), ('day', '天'), ('half_day', '半天')], string="申请单位", store=True) diff --git a/yuthon_performance/__manifest__.py b/yuthon_performance/__manifest__.py index 682f051a5..023db8ccd 100644 --- a/yuthon_performance/__manifest__.py +++ b/yuthon_performance/__manifest__.py @@ -13,6 +13,7 @@ 'depends': ['hr', 'soong_workflow',], 'data': [ 'security/ir.model.access.csv', + 'data/library_changes_data.xml', 'views/yuthon_Index_management.xml', 'views/yuthon_duty_management.xml', 'views/yuthon_performance_menus.xml', diff --git a/yuthon_performance/data/library_changes_data.xml b/yuthon_performance/data/library_changes_data.xml new file mode 100644 index 000000000..9ba277cda --- /dev/null +++ b/yuthon_performance/data/library_changes_data.xml @@ -0,0 +1,16 @@ + + + + 组织指标库-编号 + library_changes_organize_code + ZZ%(y)s%(month)s%(day)s + 3 + + + + 个人指标库-编号 + library_changes_personal_code + GR%(y)s%(month)s%(day)s + 3 + + \ No newline at end of file diff --git a/yuthon_performance/models/yuthon_Index_approval.py b/yuthon_performance/models/yuthon_Index_approval.py index 5149e2b30..12cdd88e3 100644 --- a/yuthon_performance/models/yuthon_Index_approval.py +++ b/yuthon_performance/models/yuthon_Index_approval.py @@ -9,7 +9,8 @@ class YuthonIndexApproval(models.Model): creation_time = fields.Datetime(string='申请日期', default=lambda self: fields.Datetime.now()) job_id = fields.Many2one('hr.job', string="岗位") reason_text = fields.Html(string='申请事由') - + code = fields.Char(string="编号", + default=lambda self: self.env['ir.sequence'].next_by_code('library_changes_organize_code')) change_index_library_ids = fields.One2many("yuthon.index.management",'change_index_library_id',string="组织指标库变更明细") new_index_library_ids = fields.One2many("new.index.management.line",'new_change_index_library_id',string="新组织指标库变更明细") diff --git a/yuthon_performance/models/yuthon_Index_management.py b/yuthon_performance/models/yuthon_Index_management.py index 3caaa39d4..bc911ba94 100644 --- a/yuthon_performance/models/yuthon_Index_management.py +++ b/yuthon_performance/models/yuthon_Index_management.py @@ -4,15 +4,14 @@ from odoo import models, fields, api, exceptions, _ class YuthonIndexManagement(models.Model): _name = 'yuthon.index.management' _description = "组织绩效标准库" + _rec_name = 'index_name' - 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', '否决指标'),],'指标类别') + ('gs', 'GS')],'指标类别') index_compute = fields.Char('指标计算公式', required=True) compute_type = fields.Selection([('bad_index', '反向指标'), ('good_index', '正向指标'), @@ -56,4 +55,26 @@ class YuthonIndexManagement(models.Model): "view_mode": "form", } def put_assessment_tasks_approval(self): - pass + 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, + }} + diff --git a/yuthon_performance/models/yuthon_assessment_tasks.py b/yuthon_performance/models/yuthon_assessment_tasks.py index 08a912302..3b94184be 100644 --- a/yuthon_performance/models/yuthon_assessment_tasks.py +++ b/yuthon_performance/models/yuthon_assessment_tasks.py @@ -66,3 +66,7 @@ class YuthonAssessmentTasksLines(models.Model): examiners = fields.Many2one('hr.employee',string='考核人员') be_examiners = fields.Many2one('hr.employee',string='被考核人员') assessment_status = fields.Selection([('assessment', '已考核'), ('no_assessment', '未考核')], string='考核状态') + + + def put_retake_the_exam(self): + pass diff --git a/yuthon_performance/models/yuthon_duty_management.py b/yuthon_performance/models/yuthon_duty_management.py index cbf14257c..dac3facad 100644 --- a/yuthon_performance/models/yuthon_duty_management.py +++ b/yuthon_performance/models/yuthon_duty_management.py @@ -1,5 +1,5 @@ from odoo import models, fields, api, exceptions, _ - +from datetime import datetime class YuthonDutyManagement(models.Model): _name = 'yuthon.duty.management' @@ -7,28 +7,27 @@ class YuthonDutyManagement(models.Model): _rec_name = 'name' name = fields.Char('标题') - assessment_time = fields.Char('考核时间', required=True) cycle = fields.Selection([('monthly', '月度'), ('quarter', '季度'), ('up_half', '上半年'), ('down_half', '下半年'), - ('year', '年'), ], '周期', required=True) + ('year', '年度'), ], '周期', required=True) department_id = fields.Many2one("hr.department", string="部门", required=True) start_index_time = fields.Date('指标生效时间') end_index_time = fields.Date('指标失效时间') - assessment_department_id = fields.Many2one("hr.department", string="被考核部门") + users_role_ids = fields.Many2many('soong.user.role', string='被考核角色') + users_ids = fields.Many2many('hr.employee', string='被考核人员') index_statu = fields.Selection([('work', '生效'), ('void', '作废')], '状态', required=True) # 绩效考核 performance_kpi_ids = fields.One2many('yuthon.kpi.line', 'performance_kpi_id', string="KPI") performance_gs_ids = fields.One2many('yuthon.gs.line', 'performance_gs_id', string="GS") organization_ids = fields.One2many('yuthon.role.detail.lines', 'organization_id', string="考核角色") @api.onchange('assessment_time', 'cycle', 'department_id') - def _onchange_year_department(self): - if self.cycle and self.department_id and self.assessment_time: - cycle_dict = {'monthly': '月度', 'quarter': '季度', 'up_half': '上半年', 'down_half': '下半年', - 'year': '年度'} - cycle_display = cycle_dict.get(self.cycle, self.cycle) - self.name = f"{self.assessment_time}{cycle_display}{self.department_id.name}绩效考核" + def _onchange_name(self): + cycle_dict = {'monthly': '月度', 'quarter': '季度', 'up_half': '上半年', 'down_half': '下半年', 'year': '年度'} + cycle_display = cycle_dict.get(self.cycle, self.cycle) if self.cycle else '' + department_name = self.department_id.name if self.department_id else '' + self.name = f"{self.assessment_time or ''}{cycle_display}{department_name}绩效考核" @api.model_create_multi def create(self, vals_list): @@ -41,13 +40,24 @@ class YuthonDutyManagement(models.Model): 'assessment_time': performance.assessment_time, 'performance_type':'organize' }) - return performance_records + return performance_records + + @api.model + def _get_assessment_time_options(self): + current_year = int(self.assessment_time) if self.assessment_time else datetime.now().year + return [(str(year), str(year)) for year in range(current_year, current_year + 2)] + + assessment_time = fields.Selection( + selection='_get_assessment_time_options', + string='考核时间', + required=True, + default=lambda self: str(datetime.now().year) + ) @api.model def write(self, vals): result = super().write(vals) if result: - # 只更新被修改的记录 for performance in self: tasks = self.env['yuthon.assessment.tasks'].search([('organization_id', '=', performance.id)]) tasks.write({ @@ -57,30 +67,28 @@ class YuthonDutyManagement(models.Model): }) return result + @api.depends('users_role_ids') + def _compute_users_role_ids(self): + if self.users_role_ids: + for user_id in self.users_role_ids: + user_role_data = self.env['hr.employee'].search( + ['|', ('user_role_id', '=', user_id.id.origin), ('user_role_ids', '=', user_id.id.origin)]) + users_role_list = [ro.user_id.id for ro in user_role_data] + self.users_ids = [(6, 0, users_role_list)] + class YuthonKpiLine(models.Model): _name = 'yuthon.kpi.line' _description = "KPI明细行" - + _rec_name = '' # 链接部门责任书和变更菜单 performance_kpi_id = fields.Many2one('yuthon.duty.management', string="KPI") change_duty_kpi_id = fields.Many2one('yuthon.duty.approval', string="KPI变更明细") # # KPI # 指标名称 - index_name_id = fields.Many2one('yuthon.index.management') - duty_index_name = fields.Char(related='index_name_id.index_name', string='指标名称', store=True)# + duty_index_name = fields.Many2one('yuthon.index.management',string='指标名称', store=True)# + duty_index_definition = fields.Text(related='duty_index_name.index_definition', string="指标定义") - index_definition_id = fields.Many2one('yuthon.index.management') - duty_index_definition = fields.Text(related='index_definition_id.index_definition', string="指标定义") -# -# index_id = fields.Many2one('yuthon.index.management') -# duty_index_type = fields.Selection(related='index_id.compute_type', string='计算类别', store=True) -# -# in_charge_role_id = fields.Many2one('yuthon.index.management') -# in_charge_role = fields.Many2one('soong.user.role', related='in_charge_role_id.in_charge_role', string='角色') -# -# duty_employee_id = fields.Many2one('yuthon.index.management') -# employee_id = fields.Many2one('hr.employee', related='duty_employee_id.employee_id', string="员工", store=True) #半年考核任务 half_floor_limit = fields.Float('底限值') half_benchmark_value = fields.Float('基准值') @@ -99,9 +107,7 @@ class YuthonKpiLine(models.Model): quarter_top_limit = fields.Float('努力制') unit_compute = fields.Char('计算单位') weight = fields.Char(string="权重%") -# compute_method = fields.Char(string="计算方法") -# -# + class YuthonGsLine(models.Model): _name = 'yuthon.gs.line' _description = "GS明细行" @@ -109,11 +115,10 @@ class YuthonGsLine(models.Model): # # 链接部门责任书和变更菜单 performance_gs_id = fields.Many2one('yuthon.duty.management', string="GS") change_duty_gs_id = fields.Many2one('yuthon.duty.approval', string="GS变更明细") -# # index_duty_gs_id = fields.Many2one('yuthon.index.management', string="GS变更明细") -# # 指标名称 + index_name_id = fields.Many2one('yuthon.index.management') work_task = fields.Char(related='index_name_id.index_name', string="工作任务") -# + compute_act = fields.Char(string="计划安排及具体措施/行动") node_target = fields.Char(string="节点目标") quality_objectives = fields.Char(string="质量目标") @@ -121,13 +126,5 @@ class YuthonGsLine(models.Model): quality_objectives1 = fields.Char(string="质量目标") node_target2 = fields.Char(string="节点目标") quality_objectives2 = fields.Char(string="质量目标") -# index_id = fields.Many2one('yuthon.index.management', string='Index') -# duty_index_type = fields.Selection(related='index_id.compute_type', string='计算类别', store=True) -# -# in_charge_role_id = fields.Many2one('yuthon.index.management') -# in_charge_role = fields.Many2one('soong.user.role', related='in_charge_role_id.in_charge_role', string='角色') -# -# duty_employee_id = fields.Many2one('yuthon.index.management') -# employee_id = fields.Many2one('hr.employee', string="员工", related='duty_employee_id.employee_id', store=True) -# + weight = fields.Char(string="权重%") diff --git a/yuthon_performance/models/yuthon_employee_approval.py b/yuthon_performance/models/yuthon_employee_approval.py index b0cdf8857..e34fb085f 100644 --- a/yuthon_performance/models/yuthon_employee_approval.py +++ b/yuthon_performance/models/yuthon_employee_approval.py @@ -11,10 +11,11 @@ class YuthonEmployeeApproval(models.Model): creation_time = fields.Datetime(string='申请日期', default=lambda self: fields.Datetime.now()) job_id = fields.Many2one('hr.job', string="岗位") reason_text = fields.Html(string='申请事由') + code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('library_changes_personal_code')) change_employee_library_ids = fields.One2many("yuthon.index.employee",'change_employee_library_id',string="员工指标库库变更明细") new_change_employee_library_ids = fields.One2many("new.employee.library.line",'new_change_employee_library_id',string="新员工指标库变更明细") - + users_role_ids = fields.Many2many('soong.user.role', string='被考核角色') @api.onchange('change_employee_library_ids') def _onchange_change_employee_library_ids(self): diff --git a/yuthon_performance/models/yuthon_employee_performance.py b/yuthon_performance/models/yuthon_employee_performance.py index ef99611ad..27a321972 100644 --- a/yuthon_performance/models/yuthon_employee_performance.py +++ b/yuthon_performance/models/yuthon_employee_performance.py @@ -65,11 +65,6 @@ class YuthonRoleDetailLines(models.Model): job_id = fields.Many2one('hr.job', string="考核角色") employee_id = fields.Many2one('hr.employee', string="人员") weight = fields.Float(string="权重" ) - # - # @api.onchange('role_id', 'weight') - # def _onchange_weight(self): - # if self.role_id and self.weight: - # total_weight = sum(self.search([('role_id', '=', self.role_id.id)]).mapped('weight')) - # if total_weight > 100: - # raise UserError('每个考核任务的权重之和不能大于 100%!') + + diff --git a/yuthon_performance/models/yuthon_index_employee.py b/yuthon_performance/models/yuthon_index_employee.py index ef7f014c6..eeab329cf 100644 --- a/yuthon_performance/models/yuthon_index_employee.py +++ b/yuthon_performance/models/yuthon_index_employee.py @@ -29,6 +29,19 @@ class YuthonIndexEmployee(models.Model): }} def put_assessment_tasks1_approval(self): pass + # index_applicant_ids = self.env["yuthon.index.employee"].browse( + # self._context.get('active_ids', self._context.get('active_id'))) + # for record in index_applicant_ids: + # return { + # "type": "ir.actions.act_window", + # "res_model": 'yuthon.assessment.tasks1', + # "res_id": record.id, + # "name":"员工考核任务", + # "context":{ + # "default_employee_id":record.users_role_ids.ids + # } + # } + def open_record(self): return { diff --git a/yuthon_performance/views/yuthon_Index_approval.xml b/yuthon_performance/views/yuthon_Index_approval.xml index ebc95cb32..7703af33d 100644 --- a/yuthon_performance/views/yuthon_Index_approval.xml +++ b/yuthon_performance/views/yuthon_Index_approval.xml @@ -18,26 +18,30 @@
-
-
- + + - + + + + + + + + + + @@ -51,13 +55,14 @@ -