添加功能
This commit is contained in:
@@ -29,7 +29,7 @@ class SoongWorkflowLog(models.Model):
|
||||
date_create = fields.Datetime(string="时间", default=lambda self: fields.Datetime.now())
|
||||
document_ids = fields.Many2many('ir.attachment', string="附件")
|
||||
active = fields.Boolean(string="归档", default=True)
|
||||
|
||||
is_active_operate = fields.Boolean(string="归档操作")
|
||||
display_field = fields.Char(string="显示字段", compute="_compute_display_field")
|
||||
|
||||
@api.depends("lase_click_date", "done_by")
|
||||
|
||||
@@ -110,20 +110,17 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
|
||||
def _compute_is_active(self):
|
||||
current_user_id = self.env.user.id
|
||||
if hasattr(self, 'user_id') and self.user_id:
|
||||
query_user_id = self.user_id.id
|
||||
elif hasattr(self, 'users_id') and self.users_id:
|
||||
query_user_id = self.users_id.id
|
||||
else:
|
||||
query_user_id = self.env.user.id
|
||||
if self.log_ids:
|
||||
if query_user_id == current_user_id and self.work_end and self.log_ids[-1].approval_state in ['0', '1']:
|
||||
if self.log_ids[0].done_by.id == current_user_id and self.work_end and self.log_ids[-1].approval_state in ['0', '1']:
|
||||
self.is_active = True
|
||||
else:
|
||||
self.is_active = False
|
||||
else:
|
||||
self.is_active = False
|
||||
|
||||
if self.log_ids[-1].name == '归档' and self.log_ids[-1].is_active_operate == True:
|
||||
self.is_active = False
|
||||
|
||||
def _compute_is_confirm(self):
|
||||
for record in self:
|
||||
record.is_confirm = False
|
||||
@@ -137,6 +134,10 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
if (not lg1 and not lg2) or not record.is_confirm:
|
||||
record.is_end = True
|
||||
|
||||
if record.log_ids:
|
||||
if record.log_ids[-1].name == '归档':
|
||||
record.is_end = False
|
||||
|
||||
@api.depends("node_id", "log_ids")
|
||||
def _compute_approval_sign_ids(self):
|
||||
for record in self:
|
||||
|
||||
@@ -893,6 +893,8 @@ class SoongWorkflowNodeButton(models.Model):
|
||||
result = True
|
||||
if result:
|
||||
# Run Proper Action
|
||||
if rec.action_type == 'confirm':
|
||||
rec.action_type = 'code'
|
||||
func = getattr(self, "_run_%s" % rec.action_type)
|
||||
func_result = func()
|
||||
try:
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<field name="done_by" string=""/>
|
||||
<field name="msg_id" column_invisible="1"/>
|
||||
<field name="lase_click_date" string=""/>
|
||||
<field name="is_active_operate" column_invisible="1"/>
|
||||
<field name="approval_state" string=""/>
|
||||
<field name="node_btn_name" string="" groups="soong_workflow.group_soong_workflow_manager"/>
|
||||
<field name="document_ids" string="" widget="preview_many2many"/>
|
||||
@@ -68,6 +69,7 @@
|
||||
<field name="done_by" string="" column_invisible="1"/>
|
||||
<field name="display_field" string=""/>
|
||||
<field name="lase_click_date" string="" groups="base.group_system"/>
|
||||
<field name="is_active_operate" column_invisible="1"/>
|
||||
<field name="approval_state" string=""/>
|
||||
<field name="node_btn_name" string=""/>
|
||||
<field name="document_ids" string="" widget="preview_many2many"/>
|
||||
|
||||
@@ -616,33 +616,27 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
# if not record_id.log_ids2.search([('approval_state', '=', '0')]) or record_id.log_ids2:
|
||||
last_log = record_id.log_ids[-1] if record_id.log_ids else None
|
||||
if last_log:
|
||||
applicant = None
|
||||
for field_name in ['user_id', 'users_id']:
|
||||
if hasattr(record_id, field_name):
|
||||
applicant = getattr(record_id, field_name)
|
||||
if applicant:
|
||||
break
|
||||
same_name_logs = record_id.log_ids.filtered(
|
||||
lambda log: log.name == last_log.name and log.node_btn_name == '4' and log.id != last_log.id
|
||||
)
|
||||
all_approved = all(log.approval_state == '3' for log in same_name_logs) or not same_name_logs
|
||||
all_approved = all(log.approval_state in ['2', '3'] for log in same_name_logs) or not same_name_logs
|
||||
log2_ids_all_qualified = True
|
||||
if record_id.log_ids2:
|
||||
log2_ids_all_qualified = all(log2.approval_state == '2' for log2 in record_id.log_ids2)
|
||||
log2_ids_all_qualified = all(log2.approval_state in ['2', '3'] for log2 in record_id.log_ids2)
|
||||
|
||||
if all_approved and log2_ids_all_qualified:
|
||||
if all_approved and log2_ids_all_qualified and not self.circulated_employee_ids:
|
||||
workflow_record = self.env['soong.workflow.record'].search([('code', '=', record_id.code)],
|
||||
limit=1)
|
||||
has_archive_btn = any(btn_name.name == '归档' for btn_name in self.node_btn_id.node_id.button_ids)
|
||||
if has_archive_btn:
|
||||
log_id = record_id.log_ids.filtered(lambda l: l.name == '归档')
|
||||
if workflow_record:
|
||||
workflow_record.write({
|
||||
'approve_state': 'end',
|
||||
'employee_ids': [(6, 0, [applicant.employee_ids.id])],
|
||||
'employee_ids': [(6, 0, [record_id.log_ids[0].done_by.employee_id.id])],
|
||||
'soong_state': 'to_active',
|
||||
'node_id': False,
|
||||
})
|
||||
log_id = record_id.log_ids.filtered(lambda l: l.name == '归档')
|
||||
if not log_id:
|
||||
self.env["soong.workflow.log"].create({
|
||||
'name': '归档',
|
||||
@@ -651,10 +645,19 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
"res_id": self.res_id,
|
||||
"workflow_id": self.node_btn_id.workflow_id.id,
|
||||
"lase_click_date": fields.Datetime.now(),
|
||||
"done_by": applicant.id,
|
||||
"done_by": record_id.log_ids[0].done_by.id,
|
||||
"approval_state": "0",
|
||||
"node_btn_id": self.node_btn_id.id,
|
||||
})
|
||||
else:
|
||||
log_id.write({
|
||||
"approval_state": "2",
|
||||
})
|
||||
workflow_record.write({
|
||||
'soong_state': 'active',
|
||||
'employee_ids': False,
|
||||
})
|
||||
|
||||
else:
|
||||
if workflow_record:
|
||||
workflow_record.write({
|
||||
@@ -705,7 +708,8 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
title=record_id._description,
|
||||
description=f"标题为{record_id.name}的{record_id._description}已结束,请归档",
|
||||
url=url, btntxt="查看详情")
|
||||
self.node_btn_id.with_context(cx).run()
|
||||
|
||||
self.node_btn_id.with_context(cx).run()
|
||||
if self.node_btn_name == "分发":
|
||||
record_id.is_send = True
|
||||
menu_id = self.env['ir.ui.menu'].search([('name', '=', '行政收文')])
|
||||
@@ -838,14 +842,18 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
url = self.sudo().env["wecom.apps"].generate_oauth_login_url(target_url, category='oa')
|
||||
description = "标题: {}\n".format(record_id.name) + self.env.user.name + ' ' + str(fields.Datetime.now() + timedelta(hours=8))
|
||||
record = self.env[self.res_model].search([('id', '=', self.res_id)])
|
||||
record.log_ids[-1].write({'approval_state': '2'})
|
||||
if self.document_ids:
|
||||
record.log_ids[-1].write({'document_ids': [(6, 0, self.document_ids.ids)]})
|
||||
record.log_ids[-1].write({"comment": self.comment})
|
||||
workflow_record_id = self.env['soong.workflow.record'].search([('code', '=', record_id.code)])
|
||||
workflow_record_id.write({'soong_state': 'active',
|
||||
'employee_ids':False
|
||||
record.log_ids[-1].write({'is_active_operate': True,
|
||||
'approval_state': '1'
|
||||
})
|
||||
workflow_record_id = self.env['soong.workflow.record'].search([('code', '=', record_id.code)])
|
||||
if not self.circulated_employee_ids:
|
||||
record.log_ids[-1].write({'approval_state': '2'})
|
||||
if self.document_ids:
|
||||
record.log_ids[-1].write({'document_ids': [(6, 0, self.document_ids.ids)]})
|
||||
record.log_ids[-1].write({"comment": self.comment})
|
||||
workflow_record_id.write({'soong_state': 'active',
|
||||
'employee_ids':False
|
||||
})
|
||||
if self.circulated_employee_ids:
|
||||
for employee in self.circulated_employee_ids:
|
||||
if employee.user_id.id not in log_done_by_ids:
|
||||
@@ -857,6 +865,7 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
]
|
||||
log2_id = self.sudo().env["soong.workflow.log2"].search(log2_domain, limit=1)
|
||||
if not log2_id:
|
||||
workflow_record_id.users_ids = [(4, employee.user_id.id) for employee in self.circulated_employee_ids if employee.user_id]
|
||||
log2_id = self.sudo().env["soong.workflow.log2"].create({
|
||||
"model": self.res_model,
|
||||
"res_id": self.res_id,
|
||||
|
||||
Reference in New Issue
Block a user