diff --git a/soong_workflow/models/soong_workflow_mixin.py b/soong_workflow/models/soong_workflow_mixin.py index fb7db104d..b9ff68c77 100644 --- a/soong_workflow/models/soong_workflow_mixin.py +++ b/soong_workflow/models/soong_workflow_mixin.py @@ -75,6 +75,20 @@ class SoongWorkflowMixin(models.AbstractModel): domain=lambda self: [('res_model', '=', self._name)], auto_join=True, string="审批明细") approval_sign_ids = fields.Many2many('res.users', store=False, compute="_compute_approval_sign_ids", string="加签人员") + is_back = fields.Boolean( + string='是否允许收回', + compute='_compute_is_back', + store=False, + ) + + def _compute_is_back(self): + for record in self: + record.is_back = False + if not record.log_ids: + continue + last_log = record.log_ids[-1] + if last_log.approval_state == '0': + record.is_back = True @api.depends("node_id", "log_ids") def _compute_approval_sign_ids(self): @@ -711,18 +725,18 @@ class SoongWorkflowMixin(models.AbstractModel): wkf_rec = wkf_obj.search([("model_id", "=", model), ('is_enable', '=', True)]) for node in wkf_rec.node_ids: for button in node.button_ids: - if self.env.user.has_group("soong_workflow.group_soong_workflow_manager"): - btn_exec_action_el = etree.SubElement(header_el, "button") - btn_exec_action_el.set("name", "btn_exec_action") - btn_exec_action_el.set("string", button.name) - btn_exec_action_el.set("type", "object") - if button.is_highlight: - 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) - btn_exec_action_el.set("context", "{'btn_key':'%s','active_model':'%s'}" % (button.btn_key, self._name),) - else: + # if self.env.user.has_group("soong_workflow.group_soong_workflow_manager"): + # btn_exec_action_el = etree.SubElement(header_el, "button") + # btn_exec_action_el.set("name", "btn_exec_action") + # btn_exec_action_el.set("string", button.name) + # btn_exec_action_el.set("type", "object") + # if button.is_highlight: + # 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) + # btn_exec_action_el.set("context", "{'btn_key':'%s','active_model':'%s'}" % (button.btn_key, self._name),) + # else: is_apostille = False if button.btn_hide: if button.review_type == "individual": @@ -737,14 +751,6 @@ class SoongWorkflowMixin(models.AbstractModel): elif button.review_type == "expression": if not _check_condition_code(button): continue - # # 如果是收回 - # log_ids = self.sudo().env["soong.workflow.log"].search( - # [("workflow_id", "=", wkf_rec.id), - # ("node_id", "=", node.id) - # ]) - # if log_ids and log_ids[-1].approval_state != '0': - # force_hide_withdraw = True - # Add Button to View btn_exec_action_el = etree.SubElement(header_el, "button") btn_exec_action_el.set("name", "btn_exec_action") btn_exec_action_el.set("string", button.name) @@ -759,7 +765,20 @@ class SoongWorkflowMixin(models.AbstractModel): if button.has_icon: btn_exec_action_el.set("icon", button.icon) # 接下来是隐藏的配置 - invisible = "not id or state != '{0}' ".format(str(node.node_name)) + if button.name == "收回": + next_node_names = [] + if node.out_link_ids: + next_node_names = [link.node_to.node_name for link in node.out_link_ids if link.node_to] + + if next_node_names: + state_conditions = " and ".join([f"state != '{name}'" for name in next_node_names]) + invisible = f"not id or ({state_conditions}) " + else: + # 无出链时,收回按钮永久隐藏 + invisible = "1 " + else: + invisible = f"not id or state != '{node.node_name}' " + if button.review_type == 'user_role': # 构建角色条件 role_domain = [] @@ -801,14 +820,10 @@ class SoongWorkflowMixin(models.AbstractModel): id_el = etree.Element("field") id_el.set("name", "log_ids") id_el.set("invisible", "1") - invisible += " or not log_ids" + invisible += " or not log_ids or not is_back" # if button.name == "结束": # invisible += " or True" invisible += " or work_end" - # if force_hide_withdraw and button.name == "收回": - # invisible += "1" - # btn_exec_action_el.set("invisible", "1") - # else: btn_exec_action_el.set("invisible", invisible) btn_exec_action_el.set("context", "{'btn_key':'%s','active_model':'%s'}" % (button.btn_key, self._name),) res["arch"] = etree.tostring(arch, encoding="unicode").replace("\t", "") diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml index 2e7633257..569761cc2 100644 --- a/yuthon_holiday/views/hr_leave_batch.xml +++ b/yuthon_holiday/views/hr_leave_batch.xml @@ -41,6 +41,7 @@ + diff --git a/yuthon_holiday/views/yuthon_breastfeed_leave_views.xml b/yuthon_holiday/views/yuthon_breastfeed_leave_views.xml index 82ff80755..3cadb567d 100644 --- a/yuthon_holiday/views/yuthon_breastfeed_leave_views.xml +++ b/yuthon_holiday/views/yuthon_breastfeed_leave_views.xml @@ -39,6 +39,7 @@ + diff --git a/yuthon_holiday/views/yuthon_fixes_approval_views.xml b/yuthon_holiday/views/yuthon_fixes_approval_views.xml index 984d54db4..8fd88e3fa 100644 --- a/yuthon_holiday/views/yuthon_fixes_approval_views.xml +++ b/yuthon_holiday/views/yuthon_fixes_approval_views.xml @@ -43,6 +43,7 @@ + diff --git a/yuthon_hr_attendance/views/back_approval.xml b/yuthon_hr_attendance/views/back_approval.xml index e240b9d94..1912d1245 100644 --- a/yuthon_hr_attendance/views/back_approval.xml +++ b/yuthon_hr_attendance/views/back_approval.xml @@ -39,6 +39,7 @@ + diff --git a/yuthon_hr_attendance/views/card_approval.xml b/yuthon_hr_attendance/views/card_approval.xml index 1ed4e0f78..a31b78ae1 100644 --- a/yuthon_hr_attendance/views/card_approval.xml +++ b/yuthon_hr_attendance/views/card_approval.xml @@ -44,6 +44,7 @@ + diff --git a/yuthon_hr_attendance/views/duty_approval.xml b/yuthon_hr_attendance/views/duty_approval.xml index 31eb9ade6..e963668eb 100644 --- a/yuthon_hr_attendance/views/duty_approval.xml +++ b/yuthon_hr_attendance/views/duty_approval.xml @@ -48,6 +48,7 @@ + diff --git a/yuthon_hr_attendance/views/expatriation_approval.xml b/yuthon_hr_attendance/views/expatriation_approval.xml index 583e7cbc7..968e94d80 100644 --- a/yuthon_hr_attendance/views/expatriation_approval.xml +++ b/yuthon_hr_attendance/views/expatriation_approval.xml @@ -49,6 +49,7 @@ + diff --git a/yuthon_hr_attendance/views/go_approval.xml b/yuthon_hr_attendance/views/go_approval.xml index 9a2e10285..001234a1a 100644 --- a/yuthon_hr_attendance/views/go_approval.xml +++ b/yuthon_hr_attendance/views/go_approval.xml @@ -60,6 +60,7 @@ + diff --git a/yuthon_hr_attendance/views/leave_approval.xml b/yuthon_hr_attendance/views/leave_approval.xml index 825d89b34..d16bc8363 100644 --- a/yuthon_hr_attendance/views/leave_approval.xml +++ b/yuthon_hr_attendance/views/leave_approval.xml @@ -55,6 +55,7 @@ + diff --git a/yuthon_hr_attendance/views/meal_approval.xml b/yuthon_hr_attendance/views/meal_approval.xml index 4c13b914e..7c7357e71 100644 --- a/yuthon_hr_attendance/views/meal_approval.xml +++ b/yuthon_hr_attendance/views/meal_approval.xml @@ -38,6 +38,7 @@ + diff --git a/yuthon_hr_attendance/views/overtime_approval.xml b/yuthon_hr_attendance/views/overtime_approval.xml index 52bc21e73..1e0d14f14 100644 --- a/yuthon_hr_attendance/views/overtime_approval.xml +++ b/yuthon_hr_attendance/views/overtime_approval.xml @@ -52,6 +52,7 @@ + diff --git a/yuthon_hr_attendance/views/remove_holiday_approval.xml b/yuthon_hr_attendance/views/remove_holiday_approval.xml index 1340f3bf4..12074ea02 100644 --- a/yuthon_hr_attendance/views/remove_holiday_approval.xml +++ b/yuthon_hr_attendance/views/remove_holiday_approval.xml @@ -46,6 +46,7 @@ + diff --git a/yuthon_hr_attendance/views/yuthon_abnormal_approval_views.xml b/yuthon_hr_attendance/views/yuthon_abnormal_approval_views.xml index 80c8502f9..6fc578ecf 100644 --- a/yuthon_hr_attendance/views/yuthon_abnormal_approval_views.xml +++ b/yuthon_hr_attendance/views/yuthon_abnormal_approval_views.xml @@ -44,6 +44,7 @@ + diff --git a/yuthon_hr_attendance/views/yuthon_adjustments_approval_views.xml b/yuthon_hr_attendance/views/yuthon_adjustments_approval_views.xml index 77f8527ff..8cbf7664e 100644 --- a/yuthon_hr_attendance/views/yuthon_adjustments_approval_views.xml +++ b/yuthon_hr_attendance/views/yuthon_adjustments_approval_views.xml @@ -44,6 +44,7 @@ + diff --git a/yuthon_hr_attendance/views/yuthon_customer_approval_views.xml b/yuthon_hr_attendance/views/yuthon_customer_approval_views.xml index 3e94120c7..8c12ae755 100644 --- a/yuthon_hr_attendance/views/yuthon_customer_approval_views.xml +++ b/yuthon_hr_attendance/views/yuthon_customer_approval_views.xml @@ -43,6 +43,7 @@ + diff --git a/yuthon_hr_attendance/views/yuthon_shift_approval_views.xml b/yuthon_hr_attendance/views/yuthon_shift_approval_views.xml index 4922c5e32..f8a1408b9 100644 --- a/yuthon_hr_attendance/views/yuthon_shift_approval_views.xml +++ b/yuthon_hr_attendance/views/yuthon_shift_approval_views.xml @@ -47,6 +47,7 @@ + diff --git a/yuthon_hr_attendance/views/yuthon_special_approval_views.xml b/yuthon_hr_attendance/views/yuthon_special_approval_views.xml index 0fce9865d..0cce2ef19 100644 --- a/yuthon_hr_attendance/views/yuthon_special_approval_views.xml +++ b/yuthon_hr_attendance/views/yuthon_special_approval_views.xml @@ -47,6 +47,7 @@ + diff --git a/yuthon_hr_employee_approval/models/yuthon_onboard_approval.py b/yuthon_hr_employee_approval/models/yuthon_onboard_approval.py index 80e5c11fe..7b30b54a6 100644 --- a/yuthon_hr_employee_approval/models/yuthon_onboard_approval.py +++ b/yuthon_hr_employee_approval/models/yuthon_onboard_approval.py @@ -35,7 +35,7 @@ class YuthonOnboardApproval(models.Model): bank = fields.Char(string='开户行') contract_type = fields.Selection( [('labor', ' 劳务协议 '), ('internship', ' 实习协议 '), ('part_time', ' 兼职协议 '), - ('consultant', ' 顾问 '), ('outsourcing', ' 外包 '), ('rehire', ' 返聘')], string="合同类型", + ('consultant', ' 顾问 '), ('outsourcing', ' 外包 '), ('rehire', ' 返聘')], string="非正式类型", default='labor') contract_type1 = fields.Selection([('formal', ' 正式合同 ')], string="合同类型") employment_form = fields.Selection([('formal', '正式'), ('informal', '非正式')], string="聘用形式", default='formal') diff --git a/yuthon_hr_employee_approval/views/yuthon_appointment_approval_views.xml b/yuthon_hr_employee_approval/views/yuthon_appointment_approval_views.xml index 49ee39a6f..6f0c19880 100644 --- a/yuthon_hr_employee_approval/views/yuthon_appointment_approval_views.xml +++ b/yuthon_hr_employee_approval/views/yuthon_appointment_approval_views.xml @@ -46,6 +46,7 @@ + diff --git a/yuthon_hr_employee_approval/views/yuthon_department_change_viwes.xml b/yuthon_hr_employee_approval/views/yuthon_department_change_viwes.xml index a51b9f1a4..f41739fcd 100644 --- a/yuthon_hr_employee_approval/views/yuthon_department_change_viwes.xml +++ b/yuthon_hr_employee_approval/views/yuthon_department_change_viwes.xml @@ -46,6 +46,7 @@ + diff --git a/yuthon_hr_employee_approval/views/yuthon_employee_add_views.xml b/yuthon_hr_employee_approval/views/yuthon_employee_add_views.xml index 9a9f4890e..d649edb26 100644 --- a/yuthon_hr_employee_approval/views/yuthon_employee_add_views.xml +++ b/yuthon_hr_employee_approval/views/yuthon_employee_add_views.xml @@ -38,6 +38,7 @@ + diff --git a/yuthon_hr_employee_approval/views/yuthon_interview_approval_views.xml b/yuthon_hr_employee_approval/views/yuthon_interview_approval_views.xml index f2e664974..d16ab58c7 100644 --- a/yuthon_hr_employee_approval/views/yuthon_interview_approval_views.xml +++ b/yuthon_hr_employee_approval/views/yuthon_interview_approval_views.xml @@ -49,6 +49,7 @@ + diff --git a/yuthon_hr_employee_approval/views/yuthon_leaving_approval_views.xml b/yuthon_hr_employee_approval/views/yuthon_leaving_approval_views.xml index 677cff0c5..0e17d70e7 100644 --- a/yuthon_hr_employee_approval/views/yuthon_leaving_approval_views.xml +++ b/yuthon_hr_employee_approval/views/yuthon_leaving_approval_views.xml @@ -39,6 +39,7 @@ + diff --git a/yuthon_hr_employee_approval/views/yuthon_message_login_views.xml b/yuthon_hr_employee_approval/views/yuthon_message_login_views.xml index c80918eef..b5e98ae13 100644 --- a/yuthon_hr_employee_approval/views/yuthon_message_login_views.xml +++ b/yuthon_hr_employee_approval/views/yuthon_message_login_views.xml @@ -58,6 +58,7 @@ + diff --git a/yuthon_hr_employee_approval/views/yuthon_onboard_approval_views.xml b/yuthon_hr_employee_approval/views/yuthon_onboard_approval_views.xml index 691e9eb4a..df4107aeb 100644 --- a/yuthon_hr_employee_approval/views/yuthon_onboard_approval_views.xml +++ b/yuthon_hr_employee_approval/views/yuthon_onboard_approval_views.xml @@ -47,6 +47,7 @@ + @@ -76,9 +77,9 @@ + + - -