diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py
index bf4bf9c40..d0014be33 100644
--- a/yuthon_holiday/models/yuthon_vacation_reports.py
+++ b/yuthon_holiday/models/yuthon_vacation_reports.py
@@ -348,13 +348,43 @@ class VacationMedicalLine(models.Model):
vacation_id = fields.Many2one('yuthon.vacation.reports', string='关联假期额度记录')
employee_id = fields.Many2one('hr.employee', string='员工')
workflow_record_id = fields.Many2one('soong.workflow.record', string='流程')
- update_type = fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型')
+ update_type = fields.Char(string='更新类型')
update_date = fields.Date(string='更新时间')
valid_date = fields.Date(string='有效期至')
adjust_date = fields.Date(string='调整至')
+ lines = fields.Float(string='额度')
is_void = fields.Boolean(string='是否作废', default=False)
text = fields.Text(string='备注')
+ @api.model
+ def create(self, vals):
+ record = super(VacationMedicalLine, self).create(vals)
+ if record.employee_id and record.valid_date:
+ employee = record.employee_id
+ medical_rule = self.env['medical.rules.setting'].search([
+ ('company_id', '=', employee.company_id.id),
+ ('select_year', '<=', str(record.valid_date.year))
+ ], order='select_year DESC', limit=1)
+ if medical_rule:
+ age_diff = max(0, employee.old - 20)
+ increase_times = age_diff // medical_rule.every_few_years
+ base_amount = medical_rule.base
+
+ # 根据性别和婚姻状况调整额度
+ if employee.gender == 'female':
+ if employee.marital in ['single', 'divorced', 'widower', 'cohabitant']:
+ base_amount += medical_rule.woman_unmarried
+ else:
+ base_amount += medical_rule.woman_unmarried + medical_rule.woman_married
+
+ # 计算最终额度(基础额度 + 递增额度)
+ final_amount = base_amount + (increase_times * medical_rule.increasing)
+ final_amount = min(final_amount, medical_rule.max)
+ record.write({'lines': final_amount})
+ return record
+
+
+
class DetailsTree(models.Model):
_name = 'details.tree'
_description = '明细表'
diff --git a/yuthon_hr_attendance/__manifest__.py b/yuthon_hr_attendance/__manifest__.py
index dabd24209..c5aab41fb 100644
--- a/yuthon_hr_attendance/__manifest__.py
+++ b/yuthon_hr_attendance/__manifest__.py
@@ -45,6 +45,7 @@
'views/yuthon_duty_plan_views.xml',
'views/yuthon_abnormal_approval_views.xml',
'views/yuthon_abnormal_setting_views.xml',
+ 'views/medical_rules_setting_viwes.xml',
'views/yuthon_adjustments_approval_views.xml',
'views/yuthon_shift_approval_views.xml',
'views/plan_views.xml',
diff --git a/yuthon_hr_attendance/models/__init__.py b/yuthon_hr_attendance/models/__init__.py
index 71735c45c..62c95b095 100644
--- a/yuthon_hr_attendance/models/__init__.py
+++ b/yuthon_hr_attendance/models/__init__.py
@@ -24,7 +24,7 @@ from . import yuthon_customer_planning
# from . import inherit_hr_employee
from . import hr_attendance_wechat
from . import hr_attendance_detail_wechat
-
+from . import medical_rules_setting
from . import hr_attendance_month
diff --git a/yuthon_hr_attendance/models/medical_rules_setting.py b/yuthon_hr_attendance/models/medical_rules_setting.py
new file mode 100644
index 000000000..f11c0e0d1
--- /dev/null
+++ b/yuthon_hr_attendance/models/medical_rules_setting.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from odoo import api, fields, models, tools, _
+from datetime import datetime, time, timedelta
+
+
+class MedicalRulesSetting(models.Model):
+ _name = 'medical.rules.setting'
+ _description = '体检费规则'
+
+ select_year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2040)], string='生效年',
+ default=lambda self: str(datetime.now().year))
+ base = fields.Float(string='基数')
+ every_few_years = fields.Integer(string='每几年')
+ increasing = fields.Float(string='递增')
+ woman_unmarried = fields.Float(string='女性未婚')
+ woman_married = fields.Float(string='女性已婚')
+ max = fields.Float(string='最大值')
+ company_id = fields.Many2one("res.company", string="公司", required=True)
\ No newline at end of file
diff --git a/yuthon_hr_attendance/security/ir.model.access.csv b/yuthon_hr_attendance/security/ir.model.access.csv
index f65d0f6f2..5040c969e 100644
--- a/yuthon_hr_attendance/security/ir.model.access.csv
+++ b/yuthon_hr_attendance/security/ir.model.access.csv
@@ -59,3 +59,4 @@ access_yuthon_integrated_wizard,yuthon.integrated.wizard,model_yuthon_integrated
access_applet_address,applet.address,model_applet_address,base.group_user,1,1,1,1
access_applet_security,applet.security,model_applet_security,base.group_user,1,1,1,1
access_applet_security_setting,applet.security.setting,model_applet_security_setting,base.group_user,1,1,1,1
+access_medical_rules_setting, medical.rules.setting,model_medical_rules_setting,base.group_user,1,1,1,1
diff --git a/yuthon_hr_attendance/views/medical_rules_setting_viwes.xml b/yuthon_hr_attendance/views/medical_rules_setting_viwes.xml
new file mode 100644
index 000000000..1d3dad9a4
--- /dev/null
+++ b/yuthon_hr_attendance/views/medical_rules_setting_viwes.xml
@@ -0,0 +1,24 @@
+
+
+
+ medical.rules.setting.tree
+ medical.rules.setting
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 体检费规则
+ medical.rules.setting
+ tree
+
+
\ 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 ce841dbee..43556d5ae 100644
--- a/yuthon_salary/views/inherit_hr_payslip_views.xml
+++ b/yuthon_salary/views/inherit_hr_payslip_views.xml
@@ -265,10 +265,10 @@
+
-
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml
index eed2f2b16..7509c2307 100644
--- a/yuthon_work_brand/views/hr_menus.xml
+++ b/yuthon_work_brand/views/hr_menus.xml
@@ -223,6 +223,11 @@
parent="attendance_resources_setting_root_board"
action="yuthon_holiday.action_leave_type_form"
sequence="9"/>
+