@@ -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']:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -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
|
||||
|
||||
|
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="view_medical_rules_setting_tree" model="ir.ui.view">
|
||||
<field name="name">medical.rules.setting.tree</field>
|
||||
<field name="model">medical.rules.setting</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="体检费规则" editable="bottom">
|
||||
<field name="select_year"/>
|
||||
<field name="base"/>
|
||||
<field name="every_few_years"/>
|
||||
<field name="increasing"/>
|
||||
<field name="woman_unmarried"/>
|
||||
<field name="woman_married"/>
|
||||
<field name="max"/>
|
||||
<field name="company_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_medical_rules_setting_action" model="ir.actions.act_window">
|
||||
<field name="name">体检费规则</field>
|
||||
<field name="res_model">medical.rules.setting</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -223,11 +223,6 @@
|
||||
parent="attendance_resources_setting_root_board"
|
||||
action="yuthon_holiday.action_leave_type_form"
|
||||
sequence="9"/>
|
||||
<menuitem id="medical_rules_setting_board"
|
||||
name="体检费规则"
|
||||
parent="attendance_resources_setting_root_board"
|
||||
action="yuthon_hr_attendance.view_medical_rules_setting_action"
|
||||
sequence="12"/>
|
||||
<menuitem id="holiday_set_scheme_board"
|
||||
name="年假"
|
||||
parent="attendance_resources_setting_root_board"
|
||||
|
||||
Reference in New Issue
Block a user