@@ -391,6 +391,7 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
def _add_comment(self, logs, btn_rec):
|
||||
trans_link_ids = []
|
||||
wizard = self.env.ref("soong_workflow.view_soong_workflow_comment_wizard")
|
||||
workflow_record_id = self.env["soong.workflow.record"].search([("res_model", "=", self._name), ("res_id", "=", self.id)])
|
||||
# 状态列表
|
||||
node_list = btn_rec.workflow_id.node_ids.sorted('sequence')
|
||||
if self.name_title != '采购申请单':
|
||||
@@ -405,14 +406,17 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
# 当前节点
|
||||
if btn_rec.name not in ['结束', '归档']:
|
||||
current_node = node_list[state_list.index(state)]
|
||||
# self.env['trans.link'].search([('record_id', '=', self.id)]).unlink()
|
||||
self.env['trans.link'].search([]).unlink()
|
||||
workflow_record_id = self.env["soong.workflow.record"].search(
|
||||
[("res_model", "=", self._name), ("res_id", "=", self.id)])
|
||||
self.env['trans.link'].search([('workflow_record_id', '=', workflow_record_id.id)]).unlink()
|
||||
# 退回节点根据日志进行判断
|
||||
if btn_rec.name == '退回':
|
||||
approved_logs = self.log_ids.filtered(lambda log: log.approval_state == '2')
|
||||
for ret in approved_logs:
|
||||
if not self.env['trans.link'].search([('name', '=', ret.name)]):
|
||||
self.env['trans.link'].create({
|
||||
'sequence': ret.sequence,
|
||||
'workflow_record_id': workflow_record_id.id,
|
||||
'node_button_id': btn_rec.id,
|
||||
'name': ret.name,
|
||||
'link_type': 'return',
|
||||
@@ -538,9 +542,13 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
|
||||
#根据实际路径创建trans.link记录并生成domain
|
||||
actual_path_links = []
|
||||
self.env["soong.workflow.record"].search([("res_model", "=", self._name), ("res_id", "=", self.id)])
|
||||
for node in actual_path_nodes[1:]:
|
||||
workflow_record_id = self.env["soong.workflow.record"].search([("res_model", "=", self._name), ("res_id", "=", self.id)])
|
||||
if node.name not in skipped_node_names:
|
||||
link = self.env['trans.link'].create({
|
||||
'sequence': node.sequence,
|
||||
'workflow_record_id': workflow_record_id.id,
|
||||
'node_button_id': btn_rec.id,
|
||||
'name': node.name,
|
||||
'link_type': 'trans',
|
||||
@@ -588,15 +596,16 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
"default_res_id": self.id,
|
||||
'default_comment_note_id': comment_note_id,
|
||||
"default_code": self.code,
|
||||
"default_workflow_record_id": workflow_record_id.id,
|
||||
'default_illustrate':btn_rec.node_id.illustrate,
|
||||
"default_res_model": self._name,
|
||||
"default_filter_personnel_ids": [(6, 0, all_filter_employees.ids)],
|
||||
"default_node_btn_id": btn_rec.id,
|
||||
"default_is_supervising": is_supervising,
|
||||
"default_trans_link_id": self.env['trans.link'].search(trans_domain, limit=1).id if btn_rec.name == '转交' else False,
|
||||
"default_trans_link_id": self.env['trans.link'].search(trans_domain, limit=1).sorted('sequence').id if btn_rec.name == '转交' else False,
|
||||
"all_workflow_links": trans_link_ids,
|
||||
"default_return_link_id": self.env['trans.link'].search(
|
||||
[('link_type', '=', 'return'), ('record_id', '=', self.id)], limit=1).id if btn_rec.name == '退回' else False,
|
||||
[('link_type', '=', 'return'), ('record_id', '=', self.id)], limit=1).sorted('sequence').id if btn_rec.name == '退回' else False,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@ class TransLink(models.Model):
|
||||
_rec_name = 'name'
|
||||
_order = 'sequence'
|
||||
|
||||
sequence = fields.Integer(string="转交顺序")
|
||||
workflow_record_id = fields.Many2one('soong.workflow.record', string='关联流程')
|
||||
node_button_id = fields.Many2one('soong.workflow.node.button', string="按钮")
|
||||
name = fields.Char(string="节点名称")
|
||||
link_type = fields.Selection([('trans', '转交'), ('return', '退回')], string="节点类型")
|
||||
sequence = fields.Integer(string="转交顺序")
|
||||
record_id = fields.Integer()
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<group>
|
||||
<group string="Main Information">
|
||||
<field name="name" required="1"/>
|
||||
<field name="sequence"/>
|
||||
<!-- <field name="sequence"/>-->
|
||||
</group>
|
||||
<group string="Nodes">
|
||||
<field name="node_from" required="1"/>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="sequence"/>
|
||||
<field name="workflow_record_id"/>
|
||||
<field name="name"/>
|
||||
<field name="node_button_id"/>
|
||||
<field name="link_type"/>
|
||||
|
||||
@@ -32,6 +32,7 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
comment = fields.Char(compute='_compute_comment', store=True)
|
||||
state_list = fields.Char(string="状态列表")
|
||||
record_id = fields.Integer()
|
||||
workflow_record_id = fields.Many2one('soong.workflow.record', string="流程")
|
||||
is_selection = fields.Boolean(string="是否自动选择")
|
||||
trans_link_id = fields.Many2one('trans.link', string='转交节点', ondelete='set null')
|
||||
document_ids = fields.Many2many('ir.attachment', string="附件")
|
||||
@@ -171,9 +172,6 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
for idx, link in enumerate(sorted_all_links):
|
||||
if link.id == current_link.id and link.sequence == current_link.sequence:
|
||||
approvers = self._get_approvers_for_link(link, record_id)
|
||||
# if not approvers:
|
||||
# invalid_links |= link
|
||||
|
||||
log_records = record_id.log_ids
|
||||
approved_users = log_records.filtered(lambda log: log.node_btn_name != '1' and log.done_by).mapped('done_by.employee_ids')
|
||||
approved_employee_ids = approved_users.ids
|
||||
|
||||
@@ -89,7 +89,8 @@
|
||||
<field name="is_this_company" nolabel="1"/>
|
||||
<!-- <field name="document_ids" string="附件" widget="preview_many2many" force_save="1"/>-->
|
||||
<!-- 转交人员 -->
|
||||
<field name="trans_link_id" string="转交节点" invisible="node_btn_name == '退回'" domain="[('id', 'not in', invalid_link_ids)]" options="{'no_open': True}" widget="radio" force_save="1"/>
|
||||
<field name="workflow_record_id" string="测试流程record"/>
|
||||
<field name="trans_link_id" string="转交节点" invisible="node_btn_name == '退回'" domain="[('id', 'not in', invalid_link_ids), ('workflow_record_id', '=', workflow_record_id)]" options="{'no_open': True}" widget="radio" force_save="1"/>
|
||||
<field name="employee_trans_domain_ids" invisible="1"/>
|
||||
<!-- 退回意见退回类型 -->
|
||||
<field name="return_link_id" invisible="node_btn_name != '退回'" string="退回节点" widget="radio"/>
|
||||
@@ -98,6 +99,7 @@
|
||||
<label for="is_selection" string="是否自动选择"/>
|
||||
<field name="is_selection" nolabel="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
|
||||
<field name="employee_ids1" widget="many2many_tags" string="人员范围" invisible="1"/>
|
||||
<field name="employee_ids" widget="many2many_tags" string="人员范围" domain = "[('company_id', '=', company_id), ('id', 'in', employee_ids1)] if is_this_company else [('id', 'in', employee_ids1)]" options="{'no_create': True}" context="{'tree_view_ref':'yuthon_hr_employee.view_employee_phone_tree'}"/>
|
||||
<field name="circulated_employee_ids" invisible="node_btn_name == '退回'" widget="many2many_tags" options="{'no_create': True}" domain = "[('company_id', '=', company_id),('id', 'not in' , filter_personnel_ids)]"/>
|
||||
|
||||
Reference in New Issue
Block a user