添加功能

This commit is contained in:
zhou
2025-07-15 11:43:43 +08:00
parent c1390e53e0
commit 4396d3d2eb
3 changed files with 38 additions and 2 deletions
@@ -76,8 +76,13 @@ class SoongWorkflowEntrust(models.Model):
users_role_id = reviewer_id.employee_id.user_role_id.id
for work in all_work_list:
# 判断角色是否在里面
users_role = [key for key, items in work.items() if
any(item.get('users_role_id') == users_role_id for item in items)]
users_role = [
key for key, items in work.items()
if any(
isinstance(item, dict) and item.get('users_role_id') == users_role_id
for item in items
)
]
for role in users_role:
workflow = int(role.split('-')[-1])
work_code = role.split('-')[0]
@@ -198,6 +198,24 @@ class SoongWorkflowRecord(models.Model):
target_model = self.env[rec.record_id.res_model]
target_record = target_model.sudo().browse(rec.record_id.res_id)
target_record.write({'active': True})
# 特殊处理请假审批记录
if target_model._name in ["hr.leave.batch"]:
# 恢复按天请假明细行
if target_record.leave_ids:
for leave in target_record.leave_ids:
if not leave.active:
leave.sudo().write({
'state': 'confirm',
'active': True
})
if target_record.hour_leave_ids:
for hour_leave in target_record.hour_leave_ids:
if not hour_leave.active:
hour_leave.sudo().write({
'state': 'confirm',
'active': True
})
def delete_record(self):
record_id = self.env[self.res_model].search([('id', '=', self.res_id)])
@@ -28,6 +28,19 @@ class SoongWorkflowRecordDeleteWizard(models.TransientModel):
})
target_model = self.env[record.record_id.res_model]
target_record = target_model.sudo().browse(record.record_id.res_id)
if target_model._name in ["hr.leave.batch"]:
if target_record.leave_ids:
for leave in target_record.leave_ids:
leave.sudo().write({
"state": "confirm",
"active": False
})
if target_record.hour_leave_ids:
for hour_leave in target_record.hour_leave_ids:
hour_leave.sudo().write({
"state": "confirm",
"active": False
})
target_record.write({'active': False})
else:
self.env["soong.workflow.record"].sudo().search(