diff --git a/soong_workflow/models/soong_workflow_mixin.py b/soong_workflow/models/soong_workflow_mixin.py index 6e6a948b6..8b4061fa4 100644 --- a/soong_workflow/models/soong_workflow_mixin.py +++ b/soong_workflow/models/soong_workflow_mixin.py @@ -301,71 +301,76 @@ class SoongWorkflowMixin(models.AbstractModel): index = 20 # 防止死循环 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 any( - dept in current_department or - current_department in self.get_all_sub_departments(dept) - for dept in 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 + if btn_rec.link_id: + matched_link = btn_rec.link_id + next_node = matched_link.node_to + matched_key = next_node.name + else: + 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 any( - dept in parent_department or - parent_department in self.get_all_sub_departments(dept) + dept in current_department or + current_department in self.get_all_sub_departments(dept) for dept in target_node.department_id ): valid_nodes.append((target_node, link)) - # 如果两种匹配都失败,将所有节点加入有效列表 - if not valid_nodes: - for link in current_node.out_link_ids: - valid_nodes.append((link.node_to, 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 any( + dept in parent_department or + parent_department in self.get_all_sub_departments(dept) + for dept in target_node.department_id + ): + valid_nodes.append((target_node, 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 == '转交' - ] - end_buttons = [ - btn for btn in next_node.button_ids - if btn.name == '结束' - ] - has_visible_transfer_btn = True - for btn in transfer_buttons: - if btn.is_review_invisible: - domain = eval(btn.invisible_expression) - expression_result = self.search(domain) - has_self_in_result = self.id in expression_result.ids - if not end_buttons: - if has_self_in_result: - has_visible_transfer_btn = True - break + # 如果两种匹配都失败,将所有节点加入有效列表 + 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 == '转交' + ] + end_buttons = [ + btn for btn in next_node.button_ids + if btn.name == '结束' + ] + has_visible_transfer_btn = True + for btn in transfer_buttons: + if btn.is_review_invisible: + domain = eval(btn.invisible_expression) + expression_result = self.search(domain) + has_self_in_result = self.id in expression_result.ids + if not end_buttons: + if has_self_in_result: + has_visible_transfer_btn = True + break + else: + has_visible_transfer_btn = False else: - has_visible_transfer_btn = False + has_visible_transfer_btn = True else: has_visible_transfer_btn = True - else: - has_visible_transfer_btn = True - if not has_visible_transfer_btn: - skipped_node_names.append(next_node.name) - _logger.info(f"跳过节点: {next_node.name},无可见的转交按钮") + 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) diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py index 8fbbed508..8b04040ae 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -85,13 +85,11 @@ class PropertyReconciliationWizard(models.Model): to_delete.append((2, line.id, 0)) rec.reconciliation_line_ids = to_delete - new_contract_ids = list(set(current_contract_ids) - set(bank_contract_ids)) - if new_contract_ids: - new_contracts = self.env['property.lease.contract'].browse(new_contract_ids) - new_vals, _, _ = rec.bank_id._get_reconciliation_vals(rec.bank_id, new_contracts, is_equity=True) - current_line_vals = [(4, line.id) for line in rec.reconciliation_line_ids] - rec.reconciliation_line_ids = current_line_vals + new_vals - rec.compute_reconciliation_line_ids() + new_contracts = self.env['property.lease.contract'].browse(current_contract_ids) + new_vals, _, _ = rec.bank_id._get_reconciliation_vals(rec.bank_id, new_contracts, is_equity=True) + rec.reconciliation_line_ids = [(5, 0, 0)] + rec.reconciliation_line_ids = new_vals + rec.compute_reconciliation_line_ids() @api.onchange('receivables_type_ids') def onchange_receivables_type_ids(self):