!8062 添加功能

Merge pull request !8062 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2026-01-16 11:57:47 +00:00
committed by Gitee
+18 -6
View File
@@ -90,13 +90,25 @@ class SoongWorkflowMixin(models.AbstractModel):
def _compute_is_back(self):
for record in self:
record.is_back = False
current_state = record.state
if not current_state or not record.log_ids:
current_uid = self.env.uid
user_matched_logs = record.log_ids.filtered(
lambda log: log.done_by.id == current_uid
).sorted(key=lambda log: log.create_date)
if not user_matched_logs:
continue
# 判断当前节点的状态
matched_logs = record.log_ids.filtered(lambda log: log.name == current_state)
if matched_logs:
if matched_logs[-1].approval_state == '0':
# 取当前登录人对应日志的最后一条(最新的)
current_user_last_log = user_matched_logs[-1]
all_sorted_logs = record.log_ids.sorted(key=lambda log: log.create_date)
all_sorted_list = record.log_ids.sorted(key=lambda log: log.create_date).ids
# 找到当前日志在所有日志中的索引
try:
current_log_index = all_sorted_list.index(current_user_last_log.id)
except ValueError:
current_log_index = -1
if current_log_index != -1 and (current_log_index + 1) < len(all_sorted_list):
next_log = all_sorted_logs[current_log_index + 1]
if next_log.approval_state == "0":
record.is_back = True
if record._name in ['yuthon.official.incoming.normal', 'yuthon.sub.enterprises']:
current_user_in_logs2 = any(log.done_by.id == self.env.uid for log in record.log_ids2)