diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard.py b/soong_workflow/wizard/soong_workflow_comment_wizard.py index 1f282a513..ee19520b8 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard.py +++ b/soong_workflow/wizard/soong_workflow_comment_wizard.py @@ -24,7 +24,8 @@ class SoongWorkflowCommentWizard(models.TransientModel): node_link_len = fields.Char(string="转交2") is_supervising = fields.Boolean(string="是否督办") comment_note_id = fields.Many2one('soong.note', string="常用意见", default='妥否,呈领导审批') - comment_note = fields.Char(string="意见", index=True, store=True) + comment_note = fields.Char(string="意见") + comment = fields.Char(compute='_compute_comment', store=True) state_list = fields.Char(string="状态列表") record_id = fields.Integer() trans_link_id = fields.Many2one('trans.link', string='转交节点') @@ -43,10 +44,15 @@ class SoongWorkflowCommentWizard(models.TransientModel): string="督办人员", store=True) is_automatic = fields.Boolean('是否自动匹配') - @api.onchange('comment_note_id') - def _onchange_comment_note_id(self): - if self.comment_note_id: - self.comment_note = self.comment_note_id.name + @api.depends('comment_note_id', 'comment_note') + def _compute_comment(self): + for record in self: + comment_parts = [] + if record.comment_note_id: + comment_parts.append(record.comment_note_id.name) + if record.comment_note: + comment_parts.append(record.comment_note) + record.comment = " ".join(comment_parts) if comment_parts else "" @api.depends('user_id.employee_ids.user_role_ids') def _compute_user_role_ids(self): @@ -146,10 +152,10 @@ class SoongWorkflowCommentWizard(models.TransientModel): "node_btn_id": self.node_btn_id.id, "lase_click_date": fields.Datetime.now(), "approval_state": "2", - "comment": self.comment_note, + "comment": self.comment, }) else: - now_record_obj.write({"comment": self.comment_note, + now_record_obj.write({"comment": self.comment, "approval_state": "2", "lase_click_date": fields.Datetime.now()}) next_node_id = record_id.workflow_id.node_ids.search([('name', 'ilike', self.trans_link_id.name), @@ -210,7 +216,7 @@ class SoongWorkflowCommentWizard(models.TransientModel): next_node_id = next_link.node_from record_id.log_ids[-1].write({'approval_state': '2', "lase_click_date": fields.Datetime.now(), - "comment": self.comment_note, + "comment": self.comment, "node_btn_name": "1"}) # if not self.sudo().env["soong.workflow.log"].search([('node_id', '=', next_node_id.id)]): self.sudo().env["soong.workflow.log"].create({ @@ -227,7 +233,7 @@ class SoongWorkflowCommentWizard(models.TransientModel): workflow_record_id.employee_ids = self.employee_ids return self.node_btn_id.with_context(cx).run() if self.node_btn_name == '结束': - record_id.log_ids[-1].comment = self.comment_note + record_id.log_ids[-1].comment = self.comment record_id.log_ids[-1].approval_state = "3" record_id.log_ids[-1].lase_click_date = fields.Datetime.now() record_id.work_end = True @@ -236,7 +242,7 @@ class SoongWorkflowCommentWizard(models.TransientModel): "node_id": False,}) if self.node_btn_name == "分发": if self.employee_ids: - record_id.log_ids[-1].write({"comment": self.comment_note, + record_id.log_ids[-1].write({"comment": self.comment, "approval_state": "2", "lase_click_date": fields.Datetime.now()}) self.sudo().env["soong.workflow.log"].create({ diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml b/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml index 46a3a2575..ac4ebb0bb 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml +++ b/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml @@ -16,6 +16,7 @@ +