From a69d178f1d6ccb43b87049ed1087cc3e779682cb Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Sat, 14 Jun 2025 22:40:51 +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_contract/models/inherit_hr_contract.py | 4 ++--
yuthon_hr_employee/models/yuthon_hr_employee.py | 13 ++++++++-----
yuthon_salary/models/inherit_hr_payslip.py | 11 +++++++----
yuthon_salary/models/yuthon_payroll_project.py | 2 +-
.../views/inherit_hr_payslip_run_views.xml | 4 ++--
yuthon_salary/views/inherit_hr_payslip_views.xml | 11 +++++++++++
6 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/yuthon_contract/models/inherit_hr_contract.py b/yuthon_contract/models/inherit_hr_contract.py
index b081da233..b0b5423a6 100644
--- a/yuthon_contract/models/inherit_hr_contract.py
+++ b/yuthon_contract/models/inherit_hr_contract.py
@@ -39,8 +39,8 @@ class HrContract(models.Model):
documents_ids = fields.Many2many('ir.attachment', string="合同附件")
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company', search='_search_part_of_company')
- @api.onchange('date_end')
- def _onchange_date_end(self):
+ @api.constrains("state")
+ def _constrains_state(self):
today = date.today()
if self.date_end:
if self.date_end < today:
diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py
index 660199560..a566f7e18 100644
--- a/yuthon_hr_employee/models/yuthon_hr_employee.py
+++ b/yuthon_hr_employee/models/yuthon_hr_employee.py
@@ -239,15 +239,18 @@ class YuthonHrEmployee(models.Model):
}
insurance_records = self.env['yuthon.payroll.insurances'].search([('name', 'in', list(insurance_names.keys()))])
for record in self:
- # 初始化所有保险基数为 0
+ # 初始化所有保险基数为0
for field_name in insurance_names.values():
setattr(record, field_name, 0)
- if 1 <= current_month <= 6:
- base = record.social_base_on
- else:
- base = record.social_base_off
+ base = record.social_base_on if 1 <= current_month <= 6 else record.social_base_off
for insurance in insurance_records:
field_name = insurance_names[insurance.name]
+ # 特殊处理:只有这两个人的住房公积金设为4000
+ if field_name == 'housing_fund_base' and record.name in ['郭爱娣', '黄炎方']:
+ record.housing_fund_base = 4000
+ continue # 跳过住房公积金的正常计算
+
+ # 正常计算其他保险和普通人的住房公积金
if base > insurance.employee_base_ceiling:
setattr(record, field_name, insurance.employee_base_ceiling)
elif base < insurance.employee_base_floor:
diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py
index 486795a65..caf2eadea 100644
--- a/yuthon_salary/models/inherit_hr_payslip.py
+++ b/yuthon_salary/models/inherit_hr_payslip.py
@@ -422,10 +422,13 @@ class InheritHrPayslip(models.Model):
def open_record(self):
return {
"type": "ir.actions.act_window",
- "res_model": 'hr.payslip',
- "res_id": self.id,
- "name": "薪资详情",
- "view_mode": "form",
+ "res_model": "hr.payslip.line",
+ "name": "薪资明细",
+ "view_mode": "tree",
+ "views": [(False, "tree")],
+ "domain": [("slip_id", "=", self.id), ("amount", "!=", 0)],
+ "target": "new",
+ "view_id": self.env.ref("yuthon_salary.view_hr_payslip_line_tree_custom").id,
}
def update_record(self):
diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py
index b95e6e908..cf87ddcb9 100644
--- a/yuthon_salary/models/yuthon_payroll_project.py
+++ b/yuthon_salary/models/yuthon_payroll_project.py
@@ -21,7 +21,7 @@ class YuthonPayrollCommon(models.Model):
end_date = fields.Date(string="失效日期")
before_tax = fields.Boolean(string="税前")
is_enable = fields.Boolean(string="启用", default=True)
- create_time = fields.Date(string="生效日期", default=fields.Datetime.now)
+ create_time = fields.Date(string="创建日期", default=fields.Datetime.now)
attributes = fields.Selection([('increment', '增'), ('deduction', '减')], string="工资项属性", default='increment')
@api.onchange('payroll_type_ids')
diff --git a/yuthon_salary/views/inherit_hr_payslip_run_views.xml b/yuthon_salary/views/inherit_hr_payslip_run_views.xml
index f931cbc23..c30115a0a 100644
--- a/yuthon_salary/views/inherit_hr_payslip_run_views.xml
+++ b/yuthon_salary/views/inherit_hr_payslip_run_views.xml
@@ -14,8 +14,8 @@
-
-
+
+
diff --git a/yuthon_salary/views/inherit_hr_payslip_views.xml b/yuthon_salary/views/inherit_hr_payslip_views.xml
index 4ffdd15d4..209ebfd77 100644
--- a/yuthon_salary/views/inherit_hr_payslip_views.xml
+++ b/yuthon_salary/views/inherit_hr_payslip_views.xml
@@ -492,4 +492,15 @@
tree
+
+ 薪资明细树形视图
+ hr.payslip.line
+
+
+
+
+
+
+
+