From 6ad5e0d2b93b7c61a73542bf3048e2c4069b60ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Mon, 20 Oct 2025 18:56:49 +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 --- .../models/yuthon_vacation_reports.py | 82 ++++++++++++++----- .../views/yuthon_vacation_reports_views.xml | 19 ++--- .../models/property_meter_archives.py | 2 +- .../models/property_meter_water.py | 2 +- .../views/property_meter_archives_views.xml | 10 ++- .../views/property_meter_water_views.xml | 35 ++++---- .../models/property_lease_contract.py | 5 +- 7 files changed, 103 insertions(+), 52 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 8d3d35e26..91eca465f 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -50,9 +50,9 @@ class YuthonVacationReports(models.Model): hospital_sick_leave = fields.Float(string='病假(住院期)', digits=(16, 3), compute='_compute_other_leave', store=True, group_operator=None) recovery_sick_leave = fields.Float(string='病假(出院恢复期)', digits=(16, 3), compute='_compute_other_leave', store=True, group_operator=None) exam_leave = fields.Integer(string='考试假', compute='_compute_other_leave', store=True, group_operator=None) - right_days = fields.Float(string='转正天数', group_operator=None) - internship_days = fields.Float(string='实习天数', group_operator=None, compute='compute_attendance_fields') - test_days = fields.Float(string='试用天数', group_operator=None) + right_days = fields.Float(string='转正天数', group_operator=None, compute='compute_attendance_fields') + internship_days = fields.Float(string='实习天数', group_operator=None) + test_days = fields.Float(string='试用天数', group_operator=None, compute='compute_attendance_fields') should_attendance = fields.Float(string="应到", store=True, group_operator=None, compute='compute_attendance_fields') actual_attendance = fields.Float(string="实到", compute='compute_attendance_fields', store=True,group_operator=None) @@ -168,7 +168,8 @@ class YuthonVacationReports(models.Model): is_no = 0 is_work = 0 leave_days = 0 - internship_days = 0 # 实习期天数 + test_days = 0 + right_days = 0 is_abnormal = 0 actual_attendance = 0 # 实到天数 = 应到天数 - 请假总天数 total_leave_days = 0 # 请假工作流总天数(含小时折算) @@ -179,7 +180,7 @@ class YuthonVacationReports(models.Model): days_in_month = calendar.monthrange(year, month)[1] month_start = date(year, month, 1) month_end = date(year, month, days_in_month) - leave_days, internship_days = rec._create_leave_record(rec.employee_id, month_start, month_end) + leave_days = rec._create_leave_record(rec.employee_id, month_start, month_end) entry_date = rec.employee_id.entry_date if not entry_date or month_start > entry_date: start_day = 1 @@ -221,8 +222,25 @@ class YuthonVacationReports(models.Model): actual_attendance = round(max(0, leave_days - total_leave_days), 1) - rec.internship_days = internship_days + month_start = date(year, month, 1) + month_end = date(year, month, calendar.monthrange(year, month)[1]) + leave_days = rec._create_leave_record(rec.employee_id, month_start, month_end) + probation_contract = self.env['hr.contract'].search([ + ('employee_id', '=', rec.employee_id.id), + ('is_probation', '=', True), + ('end_date', '>=', month_start), + ('end_date', '<=', month_end) + ], limit=1) + if probation_contract: + test_days = rec._create_leave_record(rec.employee_id, month_start, probation_contract.end_date) + right_days = max(0.0, leave_days - test_days) + else: + test_days = 0 + right_days = 0 + rec.should_attendance = leave_days + rec.test_days = test_days + rec.right_days = right_days rec.is_late_card = is_late rec.is_early_card = is_early rec.is_no_card = is_no @@ -321,13 +339,8 @@ class YuthonVacationReports(models.Model): shift_days_list = [self.remove_leading_zero(date) for date in shift_days_list] work_days = 0 # 工作日计数 - probation_days = 0 # 实习期工作日计数 current_date = actual_start_date - # 检查员工是否处于实习期 - contract = employee_id.contract_id - is_in_probation = contract.is_probation and contract.start_date and contract.end_date - while current_date <= end_date: current_date_str = current_date.strftime('%m月%d日') current_date_str = self.remove_leading_zero(current_date_str) @@ -339,15 +352,8 @@ class YuthonVacationReports(models.Model): if is_shift_day or (not is_weekend and not is_holiday): work_days += 1 - # 计算实习期工作日(仅对处于实习期的员工) - if is_in_probation: - # 检查当前日期是否在实习期范围内 - if (contract.start_date <= current_date <= contract.end_date): - probation_days += 1 - current_date += timedelta(days=1) - - return work_days, probation_days + return work_days def remove_leading_zero(self, date_str): month, day = date_str.split('月') @@ -917,6 +923,44 @@ class VacationMedicalLine(models.Model): return record + def create_leave_record(self, start_date, end_date): + calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")]) + holidays_list = [] + shift_days_list = [] + # 提取节假日和调休日 + for leave in calendar_leaves: + if leave.holidays: + holidays_list.extend(leave.holidays.split(',')) + if leave.alternate_rest_day: + holidays_list.extend(leave.alternate_rest_day.split(',')) + if leave.shift_replacement_day: + shift_days_list.extend(leave.shift_replacement_day.split(',')) + + holidays_list = [self.remove_leading_zero(date) for date in holidays_list] + shift_days_list = [self.remove_leading_zero(date) for date in shift_days_list] + + days = 0 # 初始化工作日计数 + current_date = start_date + + while current_date <= end_date: + current_date_str = current_date.strftime('%m月%d日') + current_date_str = self.remove_leading_zero(current_date_str) + is_weekend = current_date.weekday() in [5, 6] + + if current_date_str in holidays_list: + # 如果是法定节假日,不计为工作日 + pass + elif current_date_str in shift_days_list: + # 如果是调休日,无论是否周末都算作工作日 + days += 1 + elif not is_weekend: + # 如果不是周末且不是节假日,算作工作日 + days += 1 + + current_date += timedelta(days=1) + + return days + class VacationOtherLine(models.Model): _name = 'vacation.other.line' _description = '其他' diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml index 8aa3ef5d9..eb6647d23 100644 --- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml +++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml @@ -9,17 +9,16 @@ + + + + - - - - - @@ -56,18 +55,16 @@ - + + + + - - - - - diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py index 4849e6615..7000513fe 100644 --- a/yuthon_property/models/property_meter_archives.py +++ b/yuthon_property/models/property_meter_archives.py @@ -205,7 +205,7 @@ class PropertyMeterArchives(models.Model): class MeterArchivesLine(models.Model): _name = "meter.archives.line" _description = "电表库明细行" - _order = "number asc, sequence asc" + _order = "number asc, sequence asc, last_meter asc" archives_id = fields.Many2one("property.meter.archives", string="电表库", required=True, ondelete="cascade") # name = fields.Char(string='仪表编号') diff --git a/yuthon_property/models/property_meter_water.py b/yuthon_property/models/property_meter_water.py index cf9af1037..744ca250b 100644 --- a/yuthon_property/models/property_meter_water.py +++ b/yuthon_property/models/property_meter_water.py @@ -174,7 +174,7 @@ class PropertyMeterWater(models.Model): class MeterWaterLine(models.Model): _name = "meter.water.line" _description = "水表库明细行" - _order = "number asc, sequence asc" + _order = "number asc, sequence asc, last_meter asc" # name = fields.Char(string='仪表编号') water_id = fields.Many2one("property.meter.water", string="水表库", required=True, ondelete="cascade") diff --git a/yuthon_property/views/property_meter_archives_views.xml b/yuthon_property/views/property_meter_archives_views.xml index 4aa01127b..97c16dc83 100644 --- a/yuthon_property/views/property_meter_archives_views.xml +++ b/yuthon_property/views/property_meter_archives_views.xml @@ -13,12 +13,12 @@ + + - - - + @@ -120,7 +120,11 @@ property.meter.archives + + diff --git a/yuthon_property/views/property_meter_water_views.xml b/yuthon_property/views/property_meter_water_views.xml index 535bb8e9f..7bba8bbeb 100644 --- a/yuthon_property/views/property_meter_water_views.xml +++ b/yuthon_property/views/property_meter_water_views.xml @@ -12,22 +12,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +