@@ -454,6 +454,7 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
for node in wkf_rec.node_ids:
|
||||
for button in node.button_ids:
|
||||
# Check Condition Code
|
||||
btn_invisible = ""
|
||||
if button.btn_hide:
|
||||
if button.review_type == "individual":
|
||||
if self.env.user != button.reviewer_id:
|
||||
@@ -467,6 +468,9 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
# ('employee_id.department_id', '=', button.users_role_id.department_id.id)])
|
||||
# if self.env.user not in user_role_id:
|
||||
# continue
|
||||
# 如果是隐藏条件拼接隐藏条件
|
||||
elif button.review_type == "invisible":
|
||||
btn_invisible = button.invisible_expression
|
||||
else:
|
||||
if not _check_condition_code(button):
|
||||
continue
|
||||
@@ -479,9 +483,14 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
btn_exec_action_el.set("class", "oe_highlight")
|
||||
if button.has_icon:
|
||||
btn_exec_action_el.set("icon", button.icon)
|
||||
btn_exec_action_el.set(
|
||||
"invisible", "state != '%s'" % node.node_name
|
||||
)
|
||||
if btn_invisible:
|
||||
btn_exec_action_el.set(
|
||||
"invisible", "state != '{0}' or {1}".format(node.node_name, btn_invisible)
|
||||
)
|
||||
else:
|
||||
btn_exec_action_el.set(
|
||||
"invisible", "state != '%s'" % node.node_name
|
||||
)
|
||||
btn_exec_action_el.set(
|
||||
"context",
|
||||
"{'btn_key':'%s','active_model':'%s'}"
|
||||
|
||||
@@ -247,6 +247,7 @@ class SoongWorkflowNodeButton(models.Model):
|
||||
("group", "Any user in a specific group"),
|
||||
("expression", "Python Expression"),
|
||||
('user_role', '角色'),
|
||||
('invisible', '隐藏条件'),
|
||||
],
|
||||
)
|
||||
reviewer_id = fields.Many2one(comodel_name="res.users", string="Reviewer")
|
||||
@@ -259,6 +260,10 @@ class SoongWorkflowNodeButton(models.Model):
|
||||
"The result of executing the expression must be a res.users "
|
||||
"recordset.",
|
||||
)
|
||||
invisible_expression = fields.Text(
|
||||
string="隐藏条件",
|
||||
default="",
|
||||
)
|
||||
# todo 找翻译文件改变状态
|
||||
action_type = fields.Selection(
|
||||
[
|
||||
|
||||
@@ -169,6 +169,12 @@
|
||||
</div>
|
||||
<field name="reviewer_expression" colspan="2" required="1" widget="code" options="{'mode': 'python'}" nolabel="1"/>
|
||||
</group>
|
||||
<group invisible="review_type != 'invisible' or btn_hide == False">
|
||||
<div class="alert alert-danger oe_edit_only" role="alert" style="width: max-content;">
|
||||
<strong>备注:</strong> 这里填写按钮的隐藏条件,参考invisible的写法,invisible="name != '1' or state != '0'",这里只写 name != '1' or state != '0' 即可,注意其中的字段必须填写页面中提前声明的。
|
||||
</div>
|
||||
<field name="invisible_expression" colspan="2" required="review_type == 'invisible'" widget="code" options="{'mode': 'python'}" nolabel="1"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Actions">
|
||||
<group>
|
||||
|
||||
Reference in New Issue
Block a user