130 lines
5.9 KiB
Python
130 lines
5.9 KiB
Python
# Copyright 2017-19 ForgeFlow S.L. (https://www.forgeflow.com)
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
import pytz
|
|
|
|
from odoo import _, api, fields, models
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class SoongWorkflowLog(models.Model):
|
|
_name = "soong.workflow.log"
|
|
_description = "Soong Workflow Log"
|
|
|
|
name = fields.Char(string="节点名称", compute="_compute_name", store=True)
|
|
model = fields.Char(string="Related Document Model", index=True, required=True)
|
|
res_id = fields.Integer(string="Related Document ID", index=True, required=True)
|
|
code = fields.Char(string="流水号", index=True)
|
|
sequence = fields.Integer(string="序号", default=10)
|
|
|
|
workflow_id = fields.Many2one(comodel_name="soong.workflow")
|
|
node_id = fields.Many2one(comodel_name="soong.workflow.node")
|
|
is_return = fields.Boolean('是否返回')
|
|
msg_id = fields.Char(string="Msg_id")
|
|
node_btn_id = fields.Many2one(comodel_name="soong.workflow.node.button", string="动作名称")
|
|
node_btn_name = fields.Selection([('0', ' '), ('1', '退回'), ('2', '加签'), ('3', '串'), ('4', '并'), ('5', '董事长'), ('6', '承办')], store=True, string='节点功能', default='0')
|
|
done_by = fields.Many2one(comodel_name="res.users", string="审批人")
|
|
done_by_display = fields.Char(string="审批人显示(流程委托)")
|
|
add_sign_by = fields.Many2one(comodel_name="res.users", string="加签发起人")
|
|
lase_click_date = fields.Datetime(string="操作时间")
|
|
approval_state = fields.Selection([('0', '待办'), ('1', '办理中'), ('2', '已办结'), ('3', '结束')], string='状态', default='0')
|
|
comment = fields.Text(string="意见")
|
|
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", "done_by_display")
|
|
def _compute_display_field(self):
|
|
for record in self:
|
|
user_name = record.done_by_display or (record.done_by.name or "")
|
|
if record.lase_click_date:
|
|
lase_click_date = record.lase_click_date.strftime("%Y-%m-%d")
|
|
else:
|
|
lase_click_date = ""
|
|
record.display_field = f"{user_name} {lase_click_date}"
|
|
|
|
@api.depends("workflow_id", "node_id", "node_btn_id")
|
|
def _compute_name(self):
|
|
for rec in self:
|
|
if rec.name == '归档':
|
|
rec.name = '归档'
|
|
elif rec.name == '加签':
|
|
rec.name = '加签'
|
|
elif rec.node_id:
|
|
rec.name = "%(node_id_name)s" % {"node_id_name": rec.node_id.name}
|
|
else:
|
|
rec.name = ""
|
|
|
|
def open_record(self):
|
|
return {
|
|
"type": "ir.actions.act_window",
|
|
"res_model": 'soong.workflow.record',
|
|
"view_mode": "tree",
|
|
}
|
|
|
|
|
|
class SoongWorkflowLog2(models.Model):
|
|
_name = "soong.workflow.log2"
|
|
_description = "Soong Workflow Log2"
|
|
|
|
workflow_id = fields.Many2one(comodel_name="soong.workflow")
|
|
code = fields.Char(string="流水号", compute="_compute_code")
|
|
model = fields.Char(string="Related Document Model", index=True, required=True)
|
|
res_id = fields.Integer(string="Related Document ID", index=True, required=True)
|
|
node_id = fields.Many2one(comodel_name="soong.workflow.node")
|
|
node_btn_id = fields.Many2one(comodel_name="soong.workflow.node.button", string="动作名称")
|
|
msg_id = fields.Char(string="Msg_id")
|
|
sequence = fields.Integer(string="序号", default=10)
|
|
done_by = fields.Many2one(comodel_name="res.users", string="审批人")
|
|
done_by_display = fields.Char(string="审批人显示(流程委托)")
|
|
name = fields.Char(string="节点名称", compute="_compute_name", store=True)
|
|
approval_state = fields.Selection([('0', '待办理'), ('1', '办理中'), ('2', '已办结')], string='状态', default='0')
|
|
document_ids = fields.Many2many('ir.attachment', string="附件")
|
|
lase_click_date = fields.Datetime(string="操作时间")
|
|
commit = fields.Char(string="意见")
|
|
|
|
@api.depends("res_id", 'model')
|
|
def _compute_code(self):
|
|
for rec in self:
|
|
record = rec.env[rec.model].browse(rec.res_id)
|
|
if record:
|
|
rec.code = record.code
|
|
else:
|
|
rec.code = ""
|
|
|
|
@api.depends("workflow_id", "node_id", "node_btn_id")
|
|
def _compute_name(self):
|
|
for rec in self:
|
|
if rec.node_id and rec.node_btn_id:
|
|
rec.name = "%(node_id_name)s" % {"node_id_name": rec.node_id.name}
|
|
else:
|
|
rec.name = None
|
|
|
|
|
|
|
|
class SoongWorkflowLog3(models.Model):
|
|
_name = "soong.workflow.log3"
|
|
_description = "Soong Workflow Log3"
|
|
|
|
workflow_id = fields.Many2one(comodel_name="soong.workflow")
|
|
model = fields.Char(string="Related Document Model", index=True, required=True)
|
|
res_id = fields.Integer(string="Related Document ID", index=True, required=True)
|
|
node_id = fields.Many2one(comodel_name="soong.workflow.node")
|
|
node_btn_id = fields.Many2one(comodel_name="soong.workflow.node.button", string="动作名称")
|
|
|
|
sequence = fields.Integer(string="序号", default=10)
|
|
done_by = fields.Many2one(comodel_name="res.users", string="审批人")
|
|
name = fields.Char(string="节点名称", compute="_compute_name", store=True)
|
|
approval_state = fields.Selection([('0', '未读'), ('1', '已读')], string='状态', default='0')
|
|
document_ids = fields.Many2many('ir.attachment', string="附件")
|
|
lase_click_date = fields.Datetime(string="操作时间")
|
|
|
|
|
|
@api.depends("workflow_id", "node_id", "node_btn_id")
|
|
def _compute_name(self):
|
|
for rec in self:
|
|
rec.name = "%(node_id_name)s" % {"node_id_name": rec.node_id.name}
|
|
|