From a253b757257615931013c895ddc83ab9baba4447 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Tue, 6 May 2025 20:29:08 +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
---
excel_report_designer/models/report_excel.py | 5 +-
.../models/soong_workflow_record.py | 2 +-
soong_workflow/views/menuitem.xml | 2 +-
.../views/soong_workflow_record.xml | 1 +
.../views/hr_attendance_views.xml | 4 +-
yuthon_salary/models/inherit_hr_payslip.py | 16 +-
.../views/inherit_hr_payslip_views.xml | 5 +
yuthon_salary/wizard/salary_compute_wizard.py | 154 +++++++++---------
.../static/src/xml/task_create_button.xml | 2 +-
9 files changed, 106 insertions(+), 85 deletions(-)
diff --git a/excel_report_designer/models/report_excel.py b/excel_report_designer/models/report_excel.py
index a19ff576a..aeddbbe2c 100644
--- a/excel_report_designer/models/report_excel.py
+++ b/excel_report_designer/models/report_excel.py
@@ -491,7 +491,7 @@ class ReportExcel(models.Model):
actual_header_length = len(visible_cols)
# 写入大表头,根据实际显示列数确定合并范围
- company_year_month_text = f'员工{data["current_year"]}年{data["current_month"]}工资表({company_name})'
+ company_year_month_text = f'员工{data["current_year"]}年{data["current_month"]}月工资表({company_name})'
sheet.merge_range(0, 0, 0, actual_header_length - 1, company_year_month_text, title_format)
# 添加单位和日期
@@ -777,6 +777,7 @@ class ReportExcel(models.Model):
chinese_month = month_mapping.get(current_month)
target_name = f"{current_year}年-{chinese_month}"
return [
- ('is_push', '=', False),
+ ('is_salary_push', '=', True),
+ ('is_salary_release', '=', True),
('payslip_run_id.name', '=', target_name)
]
diff --git a/soong_workflow/models/soong_workflow_record.py b/soong_workflow/models/soong_workflow_record.py
index 0f1f8d3aa..5223717ce 100644
--- a/soong_workflow/models/soong_workflow_record.py
+++ b/soong_workflow/models/soong_workflow_record.py
@@ -37,7 +37,7 @@ class SoongWorkflowRecord(models.Model):
approvals_group_id = fields.Many2one(related='workflow_id.approvals_group_id', string="审批分组", store=True)
department_id = fields.Many2one("hr.department", string="部门", required=True)
done_by = fields.Many2one(comodel_name="res.users", string="发起人")
- # is_department_record = fields.Boolean(string="是否是本部门及以下的数据", store=False, search="_search_is_department_record")
+ is_department_record = fields.Boolean(string="是否是本部门数据", index=True)
active = fields.Boolean(string="归档", default=True)
# def get_department_employees(self, department_id):
diff --git a/soong_workflow/views/menuitem.xml b/soong_workflow/views/menuitem.xml
index e217dbd63..0e75fceaf 100644
--- a/soong_workflow/views/menuitem.xml
+++ b/soong_workflow/views/menuitem.xml
@@ -32,7 +32,7 @@
action="soong_workflow_record_action_admin"
sequence="11"/>
diff --git a/soong_workflow/views/soong_workflow_record.xml b/soong_workflow/views/soong_workflow_record.xml
index 55f630ea2..74e587fb5 100644
--- a/soong_workflow/views/soong_workflow_record.xml
+++ b/soong_workflow/views/soong_workflow_record.xml
@@ -34,6 +34,7 @@
+
diff --git a/yuthon_hr_attendance/views/hr_attendance_views.xml b/yuthon_hr_attendance/views/hr_attendance_views.xml
index 86f4fe4d3..a671dae56 100644
--- a/yuthon_hr_attendance/views/hr_attendance_views.xml
+++ b/yuthon_hr_attendance/views/hr_attendance_views.xml
@@ -9,8 +9,8 @@
editable="bottom" banner_route="/attendance/banner/route">
-
-
+
+
diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py
index 4079fb47f..0e21b1a81 100644
--- a/yuthon_salary/models/inherit_hr_payslip.py
+++ b/yuthon_salary/models/inherit_hr_payslip.py
@@ -76,6 +76,7 @@ class InheritHrPayslip(models.Model):
paid_tax = fields.Float(string='已缴税额')
based_pay = fields.Float(string='临时绩效工资')
life_salary = fields.Float(string='生活补贴')
+ january_performance = fields.Float(string='1月份绩效奖金补发')
performance_deduction = fields.Float(string='扣发绩效奖金', compute='_compute_deduction', store=True)
commuting_deduction = fields.Float(string='扣发通信补贴', compute='_compute_deduction', store=True)
@@ -205,13 +206,15 @@ class InheritHrPayslip(models.Model):
@api.depends('year_compute', 'year_jie', 'year_gong', 'jing_te', 'study_on', 'post_salary',
'seniority_salary','commuting_allowance', 'base_salary' , 'performance_bonuses',
- 'full_attendance_award', 'overtime_pay',
+ 'full_attendance_award', 'overtime_pay', 'based_pay', 'january_performance',
'high_temperature_allowance', 'performance_deduction', 'commuting_deduction', 'base_salary_deduction')
def _compute_total_before_tax(self):
for record in self:
record.total_before_tax = (
record.performance_bonuses +
record.commuting_allowance +
+ record.january_performance +
+ record.based_pay +
record.base_salary +
record.seniority_salary +
record.post_salary +
@@ -344,8 +347,17 @@ class InheritHrPayslip(models.Model):
def button_salary_print(self):
return {
"type": "ir.actions.act_window",
- "name": "导入薪资",
+ "name": "打印薪资",
"res_model": "salary.print.wizard",
"view_mode": "form",
"target": "new",
+ }
+
+ def open_record(self):
+ return {
+ "type": "ir.actions.act_window",
+ "res_model": 'hr.payslip',
+ "res_id": self.id,
+ "name": "薪资详情",
+ "view_mode": "form",
}
\ No newline at end of file
diff --git a/yuthon_salary/views/inherit_hr_payslip_views.xml b/yuthon_salary/views/inherit_hr_payslip_views.xml
index f3656a63e..8c1caa54e 100644
--- a/yuthon_salary/views/inherit_hr_payslip_views.xml
+++ b/yuthon_salary/views/inherit_hr_payslip_views.xml
@@ -87,6 +87,9 @@
hr.payslip
+
@@ -250,6 +253,7 @@
+
@@ -272,6 +276,7 @@
+
diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py
index d49af58de..72a3e4b4d 100644
--- a/yuthon_salary/wizard/salary_compute_wizard.py
+++ b/yuthon_salary/wizard/salary_compute_wizard.py
@@ -6,7 +6,7 @@ from pypinyin import pinyin, Style
import xlrd
import base64
import datetime
-from datetime import datetime
+from datetime import datetime, timedelta
class SalaryComputeWizard(models.Model):
@@ -93,92 +93,94 @@ class SalaryComputeWizard(models.Model):
})
payslip.compute_sheet()
internship_ids = self.env['hr.payslip'].search([
- ('employee_id.name', '=', '王鸿怡'),
('employee_id.contract_id.is_probation', '=', True),
('date_from', '<=', end_date),
- ('date_to', '>=', start_date)
+ ('date_to', '>=', start_date),
])
if internship_ids:
for internship_id in internship_ids:
- start_date = internship_id.date_from
- end_date = internship_id.date_to
+ original_start_date = internship_id.date_from
+ original_end_date = internship_id.date_to
contract_start_date = internship_id.employee_id.contract_id.start_date
contract_end_date = internship_id.employee_id.contract_id.end_date
- if (contract_end_date <= start_date and contract_start_date >= end_date) or (start_date < contract_start_date <= end_date):
- if internship_id.line_ids:
- target_names = {
- '基本工资': 'base_salary',
- '职级工资': 'rank_salary',
- '岗位工资': 'post_salary',
- '预发绩效奖金': 'performance_bonuses',
- '通讯补贴': 'commuting_allowance',
- '工龄工资': 'seniority_salary'
- }
- for line in internship_id.line_ids:
- if line.name in target_names:
- result = line.total * 0.8
- field_name = target_names[line.name]
- setattr(internship_id, field_name, result)
- line.write({'total': result})
- elif contract_end_date.year == end_date.year and contract_end_date.month == end_date.month:
- leave_days = self._create_leave_record(start_date, end_date)
- days = leave_days.number_of_days
- leave_days.unlink()
- days = self._process_shift_days(days, start_date, end_date) # 总工作日
- leave_internship = self._create_leave_record(start_date, contract_end_date)
- internship_days = leave_internship.number_of_days
- leave_internship.unlink()
- internship_days = self._process_shift_days(internship_days, start_date, contract_end_date) # 实习期工作日
- leave_work = self._create_leave_record(contract_end_date, end_date)
- work_days = leave_work.number_of_days
- leave_work.unlink()
- work_days = self._process_shift_days(work_days, contract_end_date, end_date) # 转正工作日
- if internship_id.line_ids:
- target_names = {
- '基本工资': 'base_salary',
- '职级工资': 'rank_salary',
- '岗位工资': 'post_salary',
- '预发绩效奖金': 'performance_bonuses',
- '通讯补贴': 'commuting_allowance',
- '工龄工资': 'seniority_salary'
- }
- for line in internship_id.line_ids:
- if line.name in target_names:
- result = line.total * 0.8 * internship_days / days + line.total * 0.8 * work_days / days
- field_name = target_names[line.name]
- setattr(internship_id, field_name, result)
- line.write({'total': result})
+ days = self._process_shift_days(original_start_date, original_end_date) # 总工作日
+ # 复制原始日期用于修改
+ start_date = original_start_date
+ end_date = original_end_date
+ # 检查 start_date 是否早于 contract_start_date
+ if start_date < contract_start_date:
+ start_date = contract_start_date
+ internship_days = self._process_shift_days(start_date, end_date) # 实习期工作日
+ # 重置为原始日期
+ start_date = original_start_date
+ end_date = original_end_date
+ # 检查 end_date 是否晚于 contract_end_date
+ if end_date > contract_end_date:
+ end_date = contract_end_date
+ work_days = self._process_shift_days(start_date, end_date) # 转正工作日
+ if internship_id.line_ids:
+ target_names = {
+ '基本工资': 'base_salary',
+ '职级工资': 'rank_salary',
+ '岗位工资': 'post_salary',
+ '预发绩效奖金': 'performance_bonuses',
+ '通讯补贴': 'commuting_allowance',
+ '工龄工资': 'seniority_salary'
+ }
+ for line in internship_id.line_ids:
+ if line.name in target_names:
+ field_name = target_names[line.name]
+ if field_name == 'performance_bonuses':
+ result = 0
+ elif field_name in ['commuting_allowance', 'seniority_salary']:
+ if work_days != days:
+ result = line.total * internship_days / days + line.total * work_days / days
+ else:
+ result = line.total * internship_days / days
+ else:
+ if work_days != days:
+ result = line.total * 0.8 * internship_days / days + line.total * work_days / days
+ else:
+ result = line.total * 0.8 * internship_days / days
+
+ setattr(internship_id, field_name, result)
+ line.write({'total': result})
def _get_chinese_month(self, month):
chinese_months = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
return chinese_months[month - 1]
- # 创建用户记录传入日期来获取天数(自然日中工作日的逻辑)
- def _create_leave_record(self, start_date, end_date):
- holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '年假')])
- admin_id = self.env['hr.employee'].search([("name", "=", 'Administrator')])
- return self.env['hr.leave'].sudo().create({
- 'employee_id': admin_id.id,
- 'holiday_status_id': holiday_status_id.id,
- 'request_date_from': start_date,
- 'request_date_to': end_date,
- 'state': 'confirm',
- })
+ def _process_shift_days(self, start_date, end_date):
+ calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ holidays_list = []
+ shift_days_list = []
+ for leaves in calendar_leaves:
+ if leaves.holidays:
+ holidays_list.extend(leaves.holidays.split(','))
+ if leaves.alternate_rest_day:
+ holidays_list.extend(leaves.alternate_rest_day.split(','))
+ if leaves.shift_replacement_day:
+ shift_days_list.extend(leaves.shift_replacement_day.split(','))
+ days = (end_date - start_date).days + 1
+ 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:
+ days -= 1
+ elif current_date_str in shift_days_list:
+ if not is_weekend:
+ days += 1
+ elif is_weekend:
+ days -= 1
+ current_date += timedelta(days=1)
+ return days
- # 行政考勤 调休日期
- def _process_shift_days(self, days, start_date, end_date):
- calendar_leaves = self.env['resource.calendar.leaves'].search([])
- all_days = []
- for calendar in calendar_leaves:
- shift_days = calendar.shift_replacement_day.split(',') if calendar.shift_replacement_day else []
- for day_str in shift_days:
- day = datetime.strptime(day_str, '%m月%d日')
- day = day.replace(year=start_date.year).date()
- all_days.append(day)
- unique_days = list(set(all_days))
- total_days = days
- for day in unique_days:
- if start_date <= day <= end_date:
- total_days += 1
- return total_days
\ No newline at end of file
+ def remove_leading_zero(self, date_str):
+ month, day = date_str.split('月')
+ month = month.lstrip('0')
+ day = day.rstrip('日')
+ day = day.lstrip('0')
+ return f'{month}月{day}日'
\ No newline at end of file
diff --git a/yuthon_will_task/static/src/xml/task_create_button.xml b/yuthon_will_task/static/src/xml/task_create_button.xml
index b12f64da3..8ec906c3c 100644
--- a/yuthon_will_task/static/src/xml/task_create_button.xml
+++ b/yuthon_will_task/static/src/xml/task_create_button.xml
@@ -5,7 +5,7 @@
-