From 38dcad930d490bd8ae7b1467fa38811a37a330a2 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Sat, 21 Jun 2025 18:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_holiday/models/inherit_hr_leave.py | 24 +++++++++++++++++++ .../models/yuthon_vacation_reports.py | 5 +++- .../views/yuthon_vacation_reports_views.xml | 4 ++++ yuthon_hr_attendance/models/go_approval.py | 22 +++++++++++++++++ .../models/overtime_approval.py | 17 +++++++++++++ .../models/yuthon_hr_employee.py | 2 +- 6 files changed, 72 insertions(+), 2 deletions(-) diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index 1a04e70f9..260f8e426 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -375,6 +375,30 @@ class HolidaysRequestBatch(models.Model): def action_submit(self): self.leave_ids.action_validate() self.hour_leave_ids.action_validate() + days = 0 + leave_list = [] + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', self.users_id.employee_id.id), + ]) + workflow_record_id = self.env['soong.workflow.record'].search([ + ('code', '=', self.code) + ]) + for line in self.hour_leave_ids: + if line.holiday_status_id.name == '年假': + match = re.search(r'(\d+(?:\.\d+)?)', line.number_of_hours_text or '') + days += float(match.group(1)) / 8 if match else 0 + for leave in self.leave_ids: + if leave.holiday_status_id.name == '年假': + days += leave.number_of_days + leave_list.append((0, 0, { + 'vacation_id': reports_id.id, + 'update_type': 'reduce', + 'workflow_record_id':workflow_record_id.id, + 'update_date': fields.Datetime.now(), + 'update_lines': days, + 'text': '审批' + })) + reports_id.write({'leave_ids': leave_list}) @api.constrains('is_day', 'is_hour', 'leave_ids', 'hour_leave_ids') def _check_leave_type_and_details(self): diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py index 6ebfc8df4..014519669 100644 --- a/yuthon_holiday/models/yuthon_vacation_reports.py +++ b/yuthon_holiday/models/yuthon_vacation_reports.py @@ -85,9 +85,11 @@ class VacationLeaveLine(models.Model): _description = '年假明细' vacation_id = fields.Many2one('yuthon.vacation.reports', string='关联假期报表') + workflow_record_id = fields.Many2one('soong.workflow.record', string='流程') update_type= fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型') update_date = fields.Date(string='更新时间') update_lines = fields.Text(string='更新额度') + text = fields.Text(string='备注') class VacationOverline(models.Model): @@ -95,18 +97,19 @@ class VacationOverline(models.Model): _description = '加班明细' vacation_id = fields.Many2one('yuthon.vacation.reports', string='关联假期报表') + workflow_record_id = fields.Many2one('soong.workflow.record', string='流程') update_type= fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型') update_date = fields.Date(string='更新时间') update_lines = fields.Text(string='更新额度') text = fields.Text(string='备注') - class VacationMealLine(models.Model): _name = 'vacation.meal.line' _description = '误餐明细' vacation_id = fields.Many2one('yuthon.vacation.reports', string='关联假期报表') + workflow_record_id = fields.Many2one('soong.workflow.record', string='流程') update_type= fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型') update_date = fields.Date(string='更新时间') update_lines = fields.Text(string='更新额度') diff --git a/yuthon_holiday/views/yuthon_vacation_reports_views.xml b/yuthon_holiday/views/yuthon_vacation_reports_views.xml index 023f3718d..7a6b0293f 100644 --- a/yuthon_holiday/views/yuthon_vacation_reports_views.xml +++ b/yuthon_holiday/views/yuthon_vacation_reports_views.xml @@ -27,9 +27,11 @@ + + @@ -37,6 +39,7 @@ + @@ -48,6 +51,7 @@ + diff --git a/yuthon_hr_attendance/models/go_approval.py b/yuthon_hr_attendance/models/go_approval.py index c8eef57cd..d7c97cac9 100644 --- a/yuthon_hr_attendance/models/go_approval.py +++ b/yuthon_hr_attendance/models/go_approval.py @@ -134,6 +134,28 @@ class GoApprovals(models.Model): # 计算结束时间 self.date_end = self.date_start + delta + def end_approval(self): + if self.meal: + self.users_id.employee_id.meal_number += 1 + # 创建日志 + go_approval_list = [] + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', self.users_id.employee_id.id), + ]) + workflow_record_id = self.env['soong.workflow.record'].search([ + ('code', '=', self.code) + ]) + go_approval_list.append((0, 0, { + 'vacation_id': reports_id.id, + 'update_type': 'add', + 'workflow_record_id': workflow_record_id.id, + 'update_date': fields.Datetime.now(), + 'update_lines': 1 , + 'text': '审批' + })) + reports_id.write({'meal_fee_ids': go_approval_list}) + + diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index e0556ab69..88616dd48 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -179,6 +179,23 @@ class OvertimeApprovals(models.Model): }) if allocation: allocation.sudo().action_validate() + # 创建日志 + overtime_list = [] + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', self.users_id.employee_id.id), + ]) + workflow_record_id = self.env['soong.workflow.record'].search([ + ('code', '=', self.code) + ]) + overtime_list.append((0, 0, { + 'vacation_id': reports_id.id, + 'update_type': 'reduce', + 'workflow_record_id': workflow_record_id.id, + 'update_date': fields.Datetime.now(), + 'update_lines': self.duration, + 'text': '审批' + })) + reports_id.write({'overtime_ids': overtime_list}) @api.depends('users_id', 'duration') def _compute_name(self): diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index a94624281..82dfa2104 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -205,7 +205,7 @@ class YuthonHrEmployee(models.Model): # 获取部门名称 department_name = record.department_id.name if record.department_id else '' # 1. 财务部会计、出纳每月有100元补贴 - if '会计岗' in (primary_role_name, *secondary_role_names) or '出纳' in ( + if '会计' in (primary_role_name, *secondary_role_names) or '出纳' in ( primary_role_name, *secondary_role_names): amount += 100 # 2. 司机分别有600元补贴(仅司机)