49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo import fields, models, api
|
|
|
|
|
|
class SoongWorkflowCommentWizard(models.TransientModel):
|
|
_name = "soong.workflow.comment.wizard"
|
|
_description = "Soong Workflow Comment Wizard"
|
|
|
|
res_model = fields.Char()
|
|
res_id = fields.Integer()
|
|
log_ids = fields.Many2many(comodel_name="soong.workflow.log")
|
|
node_btn_id = fields.Many2one(comodel_name="soong.workflow.node.button")
|
|
node_btn_name = fields.Char(string="动作名称", related='node_btn_id.name')
|
|
node_link_len = fields.Char(string="转交2")
|
|
|
|
comment_note_id = fields.Many2one('soong.note', required=True, string="意见")
|
|
comment_type = fields.Selection(related="comment_note_id.type", string="意见类型")
|
|
comment_return_type = fields.Char(related="comment_note_id.return_type", string="退回类型")
|
|
state_list = fields.Char(string="状态列表")
|
|
notice_message = fields.Char(string="消息通知")
|
|
|
|
record_id = fields.Integer()
|
|
trans_link_id = fields.Many2one('trans.link', string='转交节点')
|
|
return_link_id = fields.Many2one('trans.link', string='退回节点')
|
|
|
|
@api.onchange('record_id')
|
|
def _onchange_record_id(self):
|
|
record_id = self.env[self.res_model].search([('id', '=', self.res_id)])
|
|
self.record_id = record_id
|
|
|
|
def add_comment(self):
|
|
self.ensure_one()
|
|
cx = self.env.context.copy() or {}
|
|
record_id = self.env[self.res_model].search([('id', '=', self.res_id)])
|
|
# 转交逻辑--单线
|
|
if not self.node_link_len and self.node_btn_name == '转交':
|
|
state = self.node_btn_id.node_id.out_link_ids.name.split('-> ')[-1]
|
|
record_id.write({'state': 'end' if state == '结束' else state})
|
|
# 转交逻辑--多线
|
|
if self.node_link_len:
|
|
record_id.write({'state': 'end' if self.trans_link_id.name == '结束' else self.trans_link_id.name})
|
|
if self.node_btn_name == '退回':
|
|
record_id.write({'state': 'start' if self.return_link_id.name == '经办人' else self.return_link_id.name})
|
|
# 填写审批记录
|
|
self.log_ids.write({"comment": self.comment_note_id.name})
|
|
return self.node_btn_id.with_context(cx).run()
|