Merge pull request !7133 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-12-18 07:48:28 +00:00
committed by Gitee
3 changed files with 7 additions and 11 deletions
+5 -9
View File
@@ -229,6 +229,7 @@ class HrLeave(models.Model):
else:
hours = 0.0
holiday.number_of_hours = hours
holiday.leave_hours = hours
if holiday.holiday_status_id.type_of_work == "0":
if holiday.request_hour_from and holiday.request_hour_to:
start_hour = float(holiday.request_hour_from)
@@ -236,13 +237,17 @@ class HrLeave(models.Model):
if start_hour < 12 and end_hour > 12:
hour = end_hour - start_hour - 1
holiday.number_of_hours = hour
holiday.leave_hours = hour
elif start_hour == 9 and end_hour == 12:
holiday.number_of_hours = 4
holiday.leave_hours = 4
else:
hour = end_hour - start_hour
holiday.number_of_hours = hour
holiday.leave_hours = hour
else:
holiday.number_of_hours = 0
holiday.leave_hours = 0
# 按天请假
days = holiday.batch_id._compute_duration_day(holiday.holiday_status_id, holiday.request_date_from , holiday.request_date_to)
@@ -686,7 +691,6 @@ class HolidaysRequestBatch(models.Model):
total_days = 0
first_hour_leave = self.hour_leave_ids[0] if self.hour_leave_ids else None
holiday_status_names = []
# 处理leave_ids:收集假期类型、日期和天数
for leave in self.leave_ids:
# 收集假期类型名称(去重)
if leave.holiday_status_id and leave.holiday_status_id.name:
@@ -700,10 +704,8 @@ class HolidaysRequestBatch(models.Model):
if leave.request_date_to:
all_dates.append(leave.request_date_to)
# 累加天数
total_days += leave.number_of_days_display if hasattr(leave, 'number_of_days_display') else 0
# 处理hour_leave_ids:收集日期
for line in self.hour_leave_ids:
if line.request_date_from:
all_dates.append(line.request_date_from)
@@ -721,17 +723,11 @@ class HolidaysRequestBatch(models.Model):
# 生成名称:员工名 + 假期类型 + 日期范围 + 天数/小时
if self.employee_id:
name_parts = [f"{self.employee_id.name}的"]
# 拼接假期类型
if holiday_status_names:
name_parts.append(','.join(holiday_status_names))
# 拼接日期范围
if self.start_date and self.end_date:
date_part = f"{self.start_date.strftime('%Y-%m-%d')}~{self.end_date.strftime('%Y-%m-%d')}"
name_parts.append(date_part)
# 拼接整请假天数
if self.leave_ids:
name_parts.append(f"共计{int(total_days)}天")
+1 -1
View File
@@ -70,6 +70,7 @@
'default_employee_id': employee_id,
}" string=" " style="width: 150%;">
<tree editable="bottom">
<field name="number_of_days_display" string="天" width="100px"/>
<field name="employee_id" readonly="1" force_save="1" column_invisible="1"/>
<field name="state" column_invisible="True"/>
<field name="employee_company_id" column_invisible="True"/>
@@ -116,7 +117,6 @@
<!-- />-->
<field name="request_date_from" width="100px" string="开始日期"/>
<field name="request_date_to" width="100px" string="结束日期"/>
<field name="number_of_days_display" string="天" width="100px"/>
<field name="leave_documents_ids" widget="preview_many2many" options="{'preview_type': 'button', 'preview_string': ' '}" string=" " width="100px" readonly='true'/>
<field name="request_hour_to" column_invisible="True"/>
</tree>
@@ -6,7 +6,7 @@
<field name="arch" type="xml">
<tree string="日程任务" editable="bottom"
decoration-success="task_state == 'to_do'"
decoration-warning="task_state == 'done'"
decoration-danger="task_state == 'done'"
>
<field name="yuthon_will_task_id"/>
<field name="employee_ids" widget="many2many_tags" options="{'no_create': True}"/>