添加功能
This commit is contained in:
@@ -5,6 +5,7 @@ from odoo.tools.safe_eval import safe_eval
|
||||
from odoo.tools.misc import frozendict
|
||||
from odoo.exceptions import UserError
|
||||
from datetime import datetime, date, time, timedelta
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from lxml import etree
|
||||
import logging
|
||||
import ast
|
||||
@@ -293,29 +294,68 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
if btn_rec.name == '转交':
|
||||
node_list = list(btn_rec.workflow_id.node_ids.sorted('sequence'))
|
||||
index = self_state
|
||||
|
||||
while index < len(node_list):
|
||||
i = node_list[index]
|
||||
if not i.out_link_ids:
|
||||
current_node = node_list[index]
|
||||
|
||||
if not current_node.out_link_ids:
|
||||
index = 20 # 防止死循环
|
||||
for node in i.out_link_ids:
|
||||
matched_key = node.node_to.name
|
||||
if len(i.out_link_ids) > 1:
|
||||
result_dict = {}
|
||||
for node_to in i.out_link_ids.node_to:
|
||||
result_dict[node_to.name] = (self.get_all_sub_departments(node_to.department_id) | node_to.department_id if node_to.department_id else False)
|
||||
matched_key = next((key for key, value in result_dict.items() if value and self.department_id in value),'部门经理')
|
||||
self.env['trans.link'].create({
|
||||
'node_button_id': btn_rec.id,
|
||||
'name': matched_key,
|
||||
'sequence': node.node_to.sequence,
|
||||
'link_type': 'trans',
|
||||
'record_id': self.id,
|
||||
})
|
||||
index = state_list.index(matched_key)
|
||||
break
|
||||
# 获取当前节点的部门
|
||||
current_department = self.department_id
|
||||
# 处理多个输出链接的情况
|
||||
if len(current_node.out_link_ids) > 1:
|
||||
# 筛选与当前节点部门匹配的后续节点
|
||||
valid_nodes = []
|
||||
for link in current_node.out_link_ids:
|
||||
target_node = link.node_to
|
||||
# 如果目标节点有部门限制,且与当前节点部门匹配
|
||||
if target_node.department_id and (
|
||||
target_node.department_id == current_department or
|
||||
current_department in self.get_all_sub_departments(target_node.department_id)
|
||||
):
|
||||
valid_nodes.append((target_node, link))
|
||||
|
||||
if not valid_nodes and current_department and current_department.parent_id:
|
||||
parent_department = current_department.parent_id
|
||||
for link in current_node.out_link_ids:
|
||||
target_node = link.node_to
|
||||
if target_node.department_id and (
|
||||
target_node.department_id == parent_department or
|
||||
parent_department in self.get_all_sub_departments(target_node.department_id)
|
||||
):
|
||||
valid_nodes.append((target_node, link))
|
||||
# 如果没有找到匹配的节点,抛出错误
|
||||
if not valid_nodes:
|
||||
current_dept_name = current_department.name if current_department else "未指定部门"
|
||||
raise ValidationError(f"没有找到符合当前部门({current_dept_name})的后续节点!")
|
||||
|
||||
# 选择第一个匹配的节点
|
||||
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
|
||||
|
||||
# 创建转交链接记录
|
||||
self.env['trans.link'].create({
|
||||
'node_button_id': btn_rec.id,
|
||||
'name': matched_key,
|
||||
'sequence': next_node.sequence,
|
||||
'link_type': 'trans',
|
||||
'record_id': self.id,
|
||||
})
|
||||
|
||||
# 更新索引并跳出循环
|
||||
index = state_list.index(matched_key)
|
||||
break
|
||||
|
||||
is_supervising = False
|
||||
if self._module in ['yuthon_official']:
|
||||
is_supervising = self.is_supervising
|
||||
|
||||
return {
|
||||
"name": _("评论"),
|
||||
"type": "ir.actions.act_window",
|
||||
@@ -326,7 +366,7 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
"target": "new",
|
||||
"context": {
|
||||
"default_res_id": self.id,
|
||||
"default_code":self.code,
|
||||
"default_code": self.code,
|
||||
"default_res_model": self._name,
|
||||
"default_log_ids": logs.ids,
|
||||
"default_node_btn_id": btn_rec.id,
|
||||
|
||||
@@ -404,7 +404,7 @@ class SoongWorkflowNodeButton(models.Model):
|
||||
)
|
||||
invisible_expression_model = fields.Char(related="workflow_id.model_id.model")
|
||||
is_automatic = fields.Boolean('按当前申请人自动匹配-本部门')
|
||||
is_automatic_company = fields.Boolean('本公司')
|
||||
is_automatic_company = fields.Boolean('本公司', default=True)
|
||||
is_automatic_group = fields.Boolean('本集团')
|
||||
|
||||
is_logged_by = fields.Boolean('按当前登录人自动匹配-本部门')
|
||||
|
||||
@@ -115,7 +115,7 @@ class HrAttendance(models.Model):
|
||||
abnormal_employees.append(employee)
|
||||
|
||||
for emp in abnormal_employees:
|
||||
url = f'https://oa.thtzjt.com/web?wecom_fields={emp.user_id.wecom_fields}&oauth_uid={emp.wecom_userid}#id={self.id}&cids=2&action={menu_id.action.id}&model=hr.attendance&view_type=form&menu_id={menu_id.id}'
|
||||
url = f'https://oa.thtzjt.com/web?login={emp.user_id.login}&oauth_uid={emp.wecom_userid}#id={self.id}&cids=2&action={menu_id.action.id}&model=hr.attendance&view_type=form&menu_id={menu_id.id}'
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='attendance',
|
||||
user_id=emp.wecom_userid,
|
||||
title="打卡异常提醒",
|
||||
|
||||
@@ -112,7 +112,7 @@ class YuthonNotice(models.Model):
|
||||
menu_id = self.env['ir.ui.menu'].search([('name', '=', '通知公告'), ('parent_id', '!=', False)])
|
||||
conf_old = self.env['yuthon.confirm.users'].search([('notice_id', '=', self.id), ('employee_id', 'in', self.users_ids.ids)])
|
||||
for user_id in self.users_ids:
|
||||
url = f'https://oa.thtzjt.com/web?wecom_fields={user_id.wecom_fields}&oauth_uid={user_id.employee_id.wecom_userid}#id={self.id}&cids=2&action={menu_id.action.id}&model=yuthon.notice&view_type=form&menu_id={menu_id.id}'
|
||||
url = f'https://oa.thtzjt.com/web?login={user_id.login}&oauth_uid={user_id.employee_id.wecom_userid}#id={self.id}&cids=2&action={menu_id.action.id}&model=yuthon.notice&view_type=form&menu_id={menu_id.id}'
|
||||
if conf_old:
|
||||
for co in conf_old:
|
||||
co.write({'state': 'no'})
|
||||
|
||||
@@ -18,7 +18,7 @@ class PayslipSendWizard(models.Model):
|
||||
if not employee_id.wecom_userid:
|
||||
raise UserError("请同步{}的企业微信".format(employee_id.name))
|
||||
menu_id = self.env['ir.ui.menu'].search([('name', '=', '我的薪资')])
|
||||
url = f'https://oa.thtzjt.com/web?wecom_fields={employee_id.user_id.wecom_fields}#id={self.id}&cids=2&action={menu_id.action.id}&model=hr.payslip&view_type=form&menu_id={menu_id.id}'
|
||||
url = f'https://oa.thtzjt.com/web?login={employee_id.user_id.login}#id={self.id}&cids=2&action={menu_id.action.id}&model=hr.payslip&view_type=form&menu_id={menu_id.id}'
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='task',
|
||||
user_id=employee_id.wecom_userid,
|
||||
title="薪资确认",
|
||||
@@ -30,7 +30,7 @@ class PayslipSendWizard(models.Model):
|
||||
if not employee_id.wecom_userid:
|
||||
raise UserError("请同步{}的企业微信".format(employee_id.name))
|
||||
menu_id = self.env['ir.ui.menu'].search([('name', '=', '我的薪资')])
|
||||
url = f'https://oa.thtzjt.com/web?wecom_fields={employee_id.user_id.wecom_fields}#id={self.id}&cids=2&action={menu_id.action.id}&model=hr.payslip&view_type=form&menu_id={menu_id.id}'
|
||||
url = f'https://oa.thtzjt.com/web?login={employee_id.user_id.login}#id={self.id}&cids=2&action={menu_id.action.id}&model=hr.payslip&view_type=form&menu_id={menu_id.id}'
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='task',
|
||||
user_id=employee_id.wecom_userid,
|
||||
title="薪资确认",
|
||||
|
||||
Reference in New Issue
Block a user