From 9ac7f8414ff21c6f607a176db472446659c178c7 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Fri, 18 Jul 2025 20:24:12 +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
---
soong_workflow/models/soong_workflow_mixin.py | 62 ++++++++++---------
.../models/yuthon_vacation_reports.py | 40 ++++++------
yuthon_hr_attendance/__manifest__.py | 1 -
yuthon_hr_attendance/models/__init__.py | 1 -
.../models/medical_rules_setting.py | 18 ------
.../security/ir.model.access.csv | 1 -
.../views/medical_rules_setting_viwes.xml | 24 -------
yuthon_work_brand/views/hr_menus.xml | 5 --
8 files changed, 54 insertions(+), 98 deletions(-)
delete mode 100644 yuthon_hr_attendance/models/medical_rules_setting.py
delete mode 100644 yuthon_hr_attendance/views/medical_rules_setting_viwes.xml
diff --git a/soong_workflow/models/soong_workflow_mixin.py b/soong_workflow/models/soong_workflow_mixin.py
index 7472b6f4b..44c5c2c32 100644
--- a/soong_workflow/models/soong_workflow_mixin.py
+++ b/soong_workflow/models/soong_workflow_mixin.py
@@ -277,23 +277,18 @@ class SoongWorkflowMixin(models.AbstractModel):
'record_id': self.id,
})
if btn_rec.name == '转交':
+ skipped_node_names = [] # 因没有可用按钮而跳过的节点
node_list = list(btn_rec.workflow_id.node_ids.sorted('sequence'))
- node_name_list = [node_name.name for node_name in node_list]
index = self_state
- # 部门转入范围和条件判断才会创建
-
- # 存储实际会执行的节点路径
actual_path_nodes = []
- # 第一步:跟踪整个工作流路径,只保留实际会执行的节点
+ #跟踪整个工作流路径,只保留实际会执行的节点
while index < len(node_list):
current_node = node_list[index]
actual_path_nodes.append(current_node)
if not current_node.out_link_ids:
index = 20 # 防止死循环
break
-
- # 获取当前节点的部门
current_department = self.department_id
if len(current_node.out_link_ids) > 1:
# 筛选与当前节点部门匹配的后续节点
@@ -324,40 +319,49 @@ class SoongWorkflowMixin(models.AbstractModel):
if not valid_nodes:
for link in current_node.out_link_ids:
valid_nodes.append((link.node_to, link))
-
- # 选择第一个匹配的节点
- next_node, matched_link = valid_nodes[0]
- matched_key = next_node.name
else:
- # 只有一个输出链接,直接选择
matched_link = current_node.out_link_ids[0]
next_node = matched_link.node_to
matched_key = next_node.name
+ transfer_buttons = [
+ btn for btn in next_node.button_ids
+ if btn.name == '转交'
+ ]
+ # 判断按钮隐藏条件 如果没有可用的就跳过
+ if not transfer_buttons:
+ has_visible_transfer_btn = True
+ else:
+ has_visible_transfer_btn = any(
+ not btn.invisible_expression or
+ self.search(eval(btn.invisible_expression))
+ for btn in transfer_buttons
+ )
- # 更新索引
- index = state_list.index(matched_key)
- if index >= len(node_list):
- break
+ if not has_visible_transfer_btn:
+ skipped_node_names.append(next_node.name)
+ _logger.info(f"跳过节点: {next_node.name},无可见的转交按钮")
+ # 更新索引
+ index = state_list.index(matched_key)
+ if index >= len(node_list):
+ break
- # 第二步:根据实际路径创建trans.link记录并生成domain
+ #根据实际路径创建trans.link记录并生成domain
actual_path_links = []
- for node in actual_path_nodes[1:]: # 跳过当前节点
- link = self.env['trans.link'].create({
- 'node_button_id': btn_rec.id,
- 'name': node.name,
- 'link_type': 'trans',
- 'record_id': self.id,
- })
- actual_path_links.append(link)
+ for node in actual_path_nodes[1:]:
+ if node.name not in skipped_node_names:
+ link = self.env['trans.link'].create({
+ 'node_button_id': btn_rec.id,
+ 'name': node.name,
+ 'link_type': 'trans',
+ 'record_id': self.id,
+ })
+ actual_path_links.append(link)
- # 第三步:创建domain条件
if actual_path_links:
- # 获取所有创建的trans.link的ID
trans_link_ids = [link.id for link in actual_path_links]
- # 创建domain条件
trans_domain = [('id', 'in', trans_link_ids)]
else:
- trans_domain = [] # 如果没有路径节点,返回空domain
+ trans_domain = []
is_supervising = False
if self._module in ['yuthon_official']:
diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py
index d0014be33..9bb23ccf3 100644
--- a/yuthon_holiday/models/yuthon_vacation_reports.py
+++ b/yuthon_holiday/models/yuthon_vacation_reports.py
@@ -348,7 +348,7 @@ 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.Char(string='更新类型')
+ update_type = fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型')
update_date = fields.Date(string='更新时间')
valid_date = fields.Date(string='有效期至')
adjust_date = fields.Date(string='调整至')
@@ -358,30 +358,32 @@ class VacationMedicalLine(models.Model):
@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([
+ valid_date = record.valid_date
+ medical_rule = self.env['yuthon.medical.rule'].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
+ ('start_date', '<=', valid_date),
+ ('end_date', '>=', valid_date),
+ ('is_enable', '=', True)
+ ], limit=1)
+ age_diff = max(0, employee.old - medical_rule.starting_age)
+ increase_times = age_diff // medical_rule.increase_interval_years
+ base_amount = medical_rule.base_amount
+ if employee.gender == 'female':
+ # 将离异、丧偶、合法同居视为未婚
+ if employee.marital in ['single', 'divorced', 'widower', 'cohabitant']:
+ base_amount += medical_rule.allowance_unmarried_women
+ else:
+ base_amount += medical_rule.allowance_unmarried_women + medical_rule.allowance_married_women
- # 根据性别和婚姻状况调整额度
- 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.increment_amount)
+ final_amount = min(final_amount, medical_rule.cap)
+ record.write({'lines': final_amount})
- # 计算最终额度(基础额度 + 递增额度)
- final_amount = base_amount + (increase_times * medical_rule.increasing)
- final_amount = min(final_amount, medical_rule.max)
- record.write({'lines': final_amount})
- return record
+ return record
diff --git a/yuthon_hr_attendance/__manifest__.py b/yuthon_hr_attendance/__manifest__.py
index c5aab41fb..dabd24209 100644
--- a/yuthon_hr_attendance/__manifest__.py
+++ b/yuthon_hr_attendance/__manifest__.py
@@ -45,7 +45,6 @@
'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 62c95b095..a2eb0a30b 100644
--- a/yuthon_hr_attendance/models/__init__.py
+++ b/yuthon_hr_attendance/models/__init__.py
@@ -24,7 +24,6 @@ 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
deleted file mode 100644
index f11c0e0d1..000000000
--- a/yuthon_hr_attendance/models/medical_rules_setting.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- 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 5040c969e..f65d0f6f2 100644
--- a/yuthon_hr_attendance/security/ir.model.access.csv
+++ b/yuthon_hr_attendance/security/ir.model.access.csv
@@ -59,4 +59,3 @@ 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
deleted file mode 100644
index 1d3dad9a4..000000000
--- a/yuthon_hr_attendance/views/medical_rules_setting_viwes.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- medical.rules.setting.tree
- medical.rules.setting
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 体检费规则
- medical.rules.setting
- tree
-
-
\ No newline at end of file
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml
index 7509c2307..eed2f2b16 100644
--- a/yuthon_work_brand/views/hr_menus.xml
+++ b/yuthon_work_brand/views/hr_menus.xml
@@ -223,11 +223,6 @@
parent="attendance_resources_setting_root_board"
action="yuthon_holiday.action_leave_type_form"
sequence="9"/>
-