添加功能

This commit is contained in:
李鹏宇
2025-09-11 17:31:53 +08:00
parent 1bc4a86808
commit 5e4b4a3a2a
3 changed files with 37 additions and 29 deletions
@@ -17,34 +17,41 @@ class SoongWorkflowRecordDeleteWizard(models.TransientModel):
def add_comment(self):
for record in self.record_ids:
if self.name == "确认删除":
if record.reclaim_state is False:
self.env["soong.workflow.record"].sudo().search([("id", "=", record.id)]).write({
"reclaim_state": True
})
# 首先检查工作流记录是否存在
workflow_record = self.env["soong.workflow.record"].sudo().search([("id", "=", record.id)], limit=1)
if not workflow_record:
continue
if not record.reclaim_state:
workflow_record.write({"reclaim_state": True})
# 处理工作流日志
log_ids = self.env["soong.workflow.log"].sudo().search([("code", "=", record.code)])
for log_id in log_ids:
log_id.sudo().write({
"active": False
})
target_model = self.env[record.res_model]
target_record = target_model.sudo().browse(record.res_id)
if target_record:
if target_model._name in ["hr.leave.batch"]:
if target_record.leave_ids:
for leave in target_record.leave_ids:
leave.sudo().with_context(from_cancel_wizard=True).write({
"state": "confirm",
"active": False
})
if target_record.hour_leave_ids:
for hour_leave in target_record.hour_leave_ids:
hour_leave.sudo().with_context(from_cancel_wizard=True).write({
"state": "confirm",
"active": False
})
target_record.write({'active': False})
log_id.sudo().write({"active": False})
if record.res_model and record.res_id:
target_model = self.env[record.res_model]
target_record = target_model.sudo().browse(record.res_id).exists()
if target_record:
if target_model._name in ["hr.leave.batch"]:
if target_record.leave_ids:
for leave in target_record.leave_ids:
leave.sudo().with_context(from_cancel_wizard=True).write({
"state": "confirm",
"active": False
})
if target_record.hour_leave_ids:
for hour_leave in target_record.hour_leave_ids:
hour_leave.sudo().with_context(from_cancel_wizard=True).write({
"state": "confirm",
"active": False
})
# 确保在写入前记录仍然存在
if target_record.exists():
target_record.write({'active': False})
else:
self.env["soong.workflow.record"].sudo().search(
[("id", "=", record.id), ('reclaim_state', "=", True)]).write({
"active": False
})
workflow_record = self.env["soong.workflow.record"].sudo().search(
[("id", "=", record.id), ('reclaim_state', "=", True)], limit=1)
if workflow_record:
workflow_record.write({"active": False})
@@ -13,6 +13,7 @@ class PropertyDesignApproval(models.Model):
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门")
company_id = fields.Many2one(related='users_id.employee_id.company_id', string="公司")
project_content = fields.Char(string="工程内容")
company_a_id = fields.Many2one('yuthon.property.company', string="甲方")
company_b_id = fields.Many2one('property.construction.unit', string="乙方")
budget_list_id = fields.Many2one('ir.attachment', string="预算清单")
@@ -6,7 +6,7 @@
<field name="arch" type="xml">
<tree string="项目立项审批">
<field name="name"/>
<field name="property_id"/>
<field name="property_address"/>
<field name="amount"/>
<field name="start_date"/>
<field name="end_date"/>