From 44dd86ed2647c3f1d865d61b01d10fd7c3c7380a Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Tue, 5 Aug 2025 15:09:20 +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/__manifest__.py | 1 + yuthon_holiday/data/mothly_report_time.xml | 18 ++++++++++ .../models/yuthon_vacation_reports.py | 33 +++++++++++++++++++ .../views/yuthon_vacation_reports_views.xml | 11 +++++-- yuthon_work_brand/views/hr_menus.xml | 2 +- 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 yuthon_holiday/data/mothly_report_time.xml diff --git a/yuthon_holiday/__manifest__.py b/yuthon_holiday/__manifest__.py index 4275f9740..6a6a9b8f3 100644 --- a/yuthon_holiday/__manifest__.py +++ b/yuthon_holiday/__manifest__.py @@ -9,6 +9,7 @@ 'security/ir.model.access.csv', 'security/yuthon_holiday_group.xml', 'data/yuthon_holiday_data.xml', + 'data/mothly_report_time.xml', 'views/inherit_hr_type_views.xml', 'views/inherit_hr_leave_allocation_views.xml', 'views/inherit_hr_leave_accrual_plan_views.xml', diff --git a/yuthon_holiday/data/mothly_report_time.xml b/yuthon_holiday/data/mothly_report_time.xml new file mode 100644 index 000000000..a762fe747 --- /dev/null +++ b/yuthon_holiday/data/mothly_report_time.xml @@ -0,0 +1,18 @@ + + + + + 定时任务:生成我的考勤确认单 + + code + model.monthly_report() + + + 1 + months + + -1 + + + + diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py index f0b463a4e..8cf280782 100644 --- a/yuthon_holiday/models/yuthon_vacation_reports.py +++ b/yuthon_holiday/models/yuthon_vacation_reports.py @@ -38,6 +38,39 @@ class YuthonVacationReports(models.Model): record.medical_fee = max(total, 0.0) + def monthly_report(self): + today = fields.Date.today() + employees = self.env['hr.employee'].search([]) + for employee in employees: + existing_record = self.search([ + ('employee_id', '=', employee.id), + ('vacation_date', '=', today) + ], limit=1) + if not existing_record: + self.create({ + 'employee_id': employee.id, + 'vacation_date': today, + # 明细行和计算字段留空,由后续逻辑处理 + }) + + def disposable_report(self): + year = 2025 + months = range(1, 8) # 1到7月 + employees = self.env['hr.employee'].search([]) + for month in months: + report_date = fields.Date.from_string(f"{year}-{month:02d}-01") + for employee in employees: + existing = self.search([ + ('employee_id', '=', employee.id), + ('vacation_date', '=', report_date) + ], limit=1) + if not existing: + self.create({ + 'employee_id': employee.id, + 'vacation_date': report_date, + # 计算字段会自动触发,无需手动设置 + }) + def overtime_allocation(self): form_id = self.env.ref('hr_holidays.hr_leave_allocation_view_form_manager').id holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '补休')]) diff --git a/yuthon_holiday/views/yuthon_vacation_reports_views.xml b/yuthon_holiday/views/yuthon_vacation_reports_views.xml index a0ae22cda..f83a19262 100644 --- a/yuthon_holiday/views/yuthon_vacation_reports_views.xml +++ b/yuthon_holiday/views/yuthon_vacation_reports_views.xml @@ -10,6 +10,7 @@ +