添加功能
This commit is contained in:
@@ -536,73 +536,79 @@ class SoongWorkflowNodeButton(models.Model):
|
||||
|
||||
def run(self):
|
||||
for rec in self:
|
||||
return getattr(self, "_run_%s" % rec.action_type)
|
||||
# Check Condition Before Executing Action
|
||||
# result = False
|
||||
# cx = self.env.context.copy() or {}
|
||||
# locals_dict = {
|
||||
# "env": self.env,
|
||||
# "model": self.env[cx.get("active_model", False)],
|
||||
# "obj": self.env[cx.get("active_model", False)].browse(cx.get("active_id", 0)),
|
||||
# "user": self.env.user,
|
||||
# "datetime": datetime,
|
||||
# "time": time,
|
||||
# "date": date,
|
||||
# "timedelta": timedelta,
|
||||
# "workflow": self.env["soong.workflow"],
|
||||
# "warning": self.warning,
|
||||
# "syslog": self.syslog,
|
||||
# }
|
||||
# if rec.btn_hide:
|
||||
# if rec.review_type == "individual":
|
||||
# if rec.reviewer_id == self.env.user:
|
||||
# result = True
|
||||
# elif rec.review_type == "group":
|
||||
# if self.env.user in self.reviewer_group_id.users:
|
||||
# result = True
|
||||
# else:
|
||||
# try:
|
||||
# safe_eval(rec.reviewer_expression, locals_dict=locals_dict, mode="exec", nocopy=True,)
|
||||
# user = "user" in locals_dict and locals_dict["user"] or False
|
||||
# if user and self.env.user in user:
|
||||
# result = True
|
||||
# except ValidationError as ex:
|
||||
# raise ex
|
||||
# except SyntaxError as ex:
|
||||
# raise UserError(
|
||||
# _(
|
||||
# "Wrong python code defined.\n\nError: %s\nLine: %s, Column: %s\n\n%s"
|
||||
# % (
|
||||
# ex.args[0],
|
||||
# ex.args[1][1],
|
||||
# ex.args[1][2],
|
||||
# ex.args[1][3],
|
||||
# )
|
||||
# )
|
||||
# )
|
||||
# else:
|
||||
# result = True
|
||||
# if result:
|
||||
# Run Proper Action
|
||||
# func = getattr(self, "_run_%s" % rec.action_type)
|
||||
# func_result = func()
|
||||
# try:
|
||||
# user_ids = []
|
||||
# button_ids = rec.link_id.node_to.button_ids
|
||||
# for button_id in button_ids:
|
||||
# # 根据每个按钮状态判断当前应该的查看人员
|
||||
# if button_id.review_type == "individual":
|
||||
# user_ids.append(button_id.reviewer_id.id)
|
||||
# elif button_id.review_type == "group":
|
||||
# user_ids += button_id.reviewer_group_id.users.ids
|
||||
# elif button_id.review_type == "user_role":
|
||||
# user_role_id = self.env['res.users'].search(
|
||||
# [('employee_id.user_role_id', '=', button_id.users_role_id.id)])
|
||||
# user_ids += user_role_id.ids
|
||||
# # 发送信息提醒
|
||||
# partner_ids = self.sudo().env['res.users'].search([('id', 'in', user_ids)]).mapped('partner_id').ids
|
||||
# self.sudo().with_context(lang=self.env.lang)._message_auto_subscribe_notify(partner_ids, 'soong_workflow.message_yuthon_workflow_btn_approval_data')
|
||||
# return getattr(self, "_run_%s" % rec.action_type)
|
||||
result = False
|
||||
cx = self.env.context.copy() or {}
|
||||
locals_dict = {
|
||||
"env": self.env,
|
||||
"model": self.env[cx.get("active_model", False)],
|
||||
"obj": self.env[cx.get("active_model", False)].browse(cx.get("active_id", 0)),
|
||||
"user": self.env.user,
|
||||
"datetime": datetime,
|
||||
"time": time,
|
||||
"date": date,
|
||||
"timedelta": timedelta,
|
||||
"workflow": self.env["soong.workflow"],
|
||||
"warning": self.warning,
|
||||
"syslog": self.syslog,
|
||||
}
|
||||
if rec.btn_hide:
|
||||
if rec.review_type == "individual":
|
||||
if rec.reviewer_id == self.env.user:
|
||||
result = True
|
||||
elif rec.review_type == "group":
|
||||
if self.env.user in self.reviewer_group_id.users:
|
||||
result = True
|
||||
else:
|
||||
try:
|
||||
safe_eval(
|
||||
rec.reviewer_expression,
|
||||
locals_dict=locals_dict,
|
||||
mode="exec",
|
||||
nocopy=True,
|
||||
)
|
||||
user = "user" in locals_dict and locals_dict["user"] or False
|
||||
if user and self.env.user in user:
|
||||
result = True
|
||||
except ValidationError as ex:
|
||||
raise ex
|
||||
except SyntaxError as ex:
|
||||
raise UserError(
|
||||
_(
|
||||
"Wrong python code defined.\n\nError: %s\nLine: %s, Column: %s\n\n%s"
|
||||
% (
|
||||
ex.args[0],
|
||||
ex.args[1][1],
|
||||
ex.args[1][2],
|
||||
ex.args[1][3],
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
result = True
|
||||
if result:
|
||||
# Run Proper Action
|
||||
func = getattr(self, "_run_%s" % rec.action_type)
|
||||
func_result = func()
|
||||
try:
|
||||
user_ids = []
|
||||
button_ids = rec.link_id.node_to.button_ids
|
||||
for button_id in button_ids:
|
||||
# 根据每个按钮状态判断当前应该的查看人员
|
||||
if button_id.review_type == "individual":
|
||||
user_ids.append(button_id.reviewer_id.id)
|
||||
elif button_id.review_type == "group":
|
||||
user_ids += button_id.reviewer_group_id.users.ids
|
||||
elif button_id.review_type == "user_role":
|
||||
user_role_id = self.env['res.users'].search(
|
||||
[('employee_id.user_role_id', '=', button_id.users_role_id.id)])
|
||||
user_ids += user_role_id.ids
|
||||
# # 发送信息提醒
|
||||
# partner_ids = self.sudo().env['res.users'].search([('id', 'in', user_ids)]).mapped('partner_id').ids
|
||||
# self.sudo().with_context(lang=self.env.lang)._message_auto_subscribe_notify(partner_ids, 'soong_workflow.message_yuthon_workflow_btn_approval_data')
|
||||
except Exception as e:
|
||||
pass
|
||||
return func_result
|
||||
|
||||
def _run_win_act(self):
|
||||
# Variables
|
||||
|
||||
Reference in New Issue
Block a user