This commit is contained in:
李鹏宇
2025-02-10 15:51:10 +08:00
parent cf45d076e2
commit a22da5ded5
8 changed files with 35 additions and 6 deletions
@@ -475,6 +475,10 @@ class SoongWorkflowMixin(models.AbstractModel):
def unlink(self):
self.mapped("log_ids").unlink()
self.mapped("log_ids2").unlink()
if self.env.user.name != 'Administrator':
if len(self.log_ids) > 1:
raise UserError("该流程不允许删除,如果要调整请联系管理员")
record_objs = self.env["soong.workflow.record"].search([("res_model", "=", self._name), ("res_id", "in", self.ids)])
record_objs.unlink()
return super(SoongWorkflowMixin, self).unlink()
@@ -44,6 +44,7 @@ START_BG_COLOR = "rgba(120,120,120,1)"
START_LABEL_COLOR = "rgba(255,255,255,1)"
END_BG_COLOR = "rgba(120,120,120,1)"
END_LABEL_COLOR = "rgba(255,255,255,1)"
END_BG_COLOR_1 = "rgba(0,255,30,1)"
class SoongWorkflowNode(models.Model):
@@ -87,6 +88,7 @@ class SoongWorkflowNode(models.Model):
is_carbon_copy = fields.Boolean(string="抄送/传阅")
is_apostille = fields.Boolean(string="加签", default=False)
employee_ids = fields.Many2many('hr.employee', string='抄送/传阅人员')
is_end = fields.Boolean(string="结束")
@api.onchange("is_apostille")
def onchange_is_apostille(self):
@@ -116,6 +118,27 @@ class SoongWorkflowNode(models.Model):
else:
record.button_ids.filtered(lambda r: r.name in ["加签", "加签确认"]).unlink()
@api.onchange("is_end")
def onchange_is_end(self):
for record in self:
if record.is_end:
record.res_bg_color = END_BG_COLOR_1
sequence = max([r.sequence for r in record.button_ids] if record.button_ids else [1])
record.button_ids = [
(0, 0, {
"name": _("结束"),
"workflow_id": record.workflow_id,
"node_id": record.id,
"sequence": sequence + 1,
"action_type": "code",
"btn_hide": False # 对所有人显示
})
]
else:
record.res_bg_color = DEFAULT_BG_COLOR
record.button_ids.filtered(lambda r: r.name in ["结束"]).unlink()
@api.model_create_multi
def create(self, values):
records = super().create(values)
@@ -59,6 +59,8 @@ class SoongWorkflowRecord(models.Model):
def reclaim_record(self):
for rec in self:
record_id = self.env[self.res_model].search([('id', '=', self.res_id)])
record_id.write({'active': False})
rec.reclaim_state = True
def restore_record(self):
@@ -37,6 +37,7 @@
<field name="is_carbon_copy"/>
<field name="is_apostille"/>
<field name="employee_ids" widget="many2many_tags" invisible="not is_carbon_copy"/>
<field name="is_end"/>
</group>
</group>
<notebook>
@@ -133,8 +133,6 @@ class SoongWorkflowCommentWizard(models.TransientModel):
for next in record_id.workflow_id.link_ids:
self_link = next.name.split('-> ')[0].strip()
next_link = next.name.split('-> ')[-1].strip()
# 拟办申请人,无start
self_link = 'start' if self_link in ['拟办', '申请人'] else self_link
if record_id.state == self_link and next_link == self.trans_link_id.name.strip():
next_node_id = record_id.workflow_id.node_ids.search([('name', 'ilike', self.trans_link_id.name), ('workflow_id', '=', record_id.workflow_id.id)])
# 分发判断
@@ -9,7 +9,7 @@
<field name="arch" type="xml">
<form string="意见">
<group invisible="node_btn_name == '分发'">
<field name="comment_note_id" require="1" string="分发意见"/>
<field name="comment_note_id" require="1"/>
<field name="node_btn_id" invisible="1"/>
<field name="node_btn_name" invisible="1"/>
<field name="node_link_len" invisible="1"/>
@@ -22,7 +22,7 @@
<field name="employee_ids" widget="many2many_tags" string="人员范围"/>
</group>
<group invisible="node_btn_name != '分发'">
<field name="comment_note_id" require="1"/>
<field name="comment_note_id" require="1" string="分发意见"/>
<field name="employee_ids" widget="many2many_tags" string="董事长"/>
<field name="circulated_employee_ids" widget="many2many_tags"/>
<field name="supervising_employee_ids" widget="many2many_tags"/>
@@ -26,6 +26,7 @@ class CardApprovals(models.Model):
documents_ids = fields.Many2many('ir.attachment', string="附件")
attendance_id = fields.Many2one('hr.attendance', string="补卡日期")
replacement_time = fields.Selection([('work', '上班卡'), ('quitting', '下班卡'), ('all', '全天卡')], string="补卡")
active = fields.Boolean('Active', default=True)
@api.onchange('attendance_id')
def onchange_replacement_time(self):
@@ -17,7 +17,7 @@ class HrJob(models.Model):
for rec in self.env['yuthon.recruitment.approval'].search([]):
for i in rec.recruitment_ids:
if pub.id == i.id:
rec.is_pub = True
pub.is_pub = True
raise UserError('该岗位已经发布申请,请勿重复提交,到对应流程中查看,流程的流水号为 %s' % rec.code)
hr_job_ids = self.env["hr.job"].browse(self._context.get('active_ids', self._context.get('active_id')))
first_department_id = hr_job_ids[0].department_id
@@ -49,7 +49,7 @@ class HrJob(models.Model):
hr_job_list = []
for job in hr_job_ids:
hr_job_list.append([0, 0, {
'hr_job_id':job.id,
'hr_job_id': job.id,
'department_id': job.department_id.id,
'job_type_id': job.job_type_id.id,
'yuthon_company': job.yuthon_company,