49 lines
2.1 KiB
Python
49 lines
2.1 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"
|
|
|
|
# _sql_constraints = [(
|
|
# "uniq_node_btn_id",
|
|
# "unique(model, res_id, node_btn_id)",
|
|
# _("Workflow log must be unique."),), ]
|
|
|
|
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)
|
|
|
|
# w_res_id = fields.Many2oneReference(string='Workflow Ref.', index=True, model_field='w_res_model_id')
|
|
# w_res_model_id = fields.Many2one('ir.model', string='Model', index=True, ondelete='cascade')
|
|
# w_res_model = fields.Char('Workflow Ref Model', index=True, related='w_res_model_id.model', precompute=True, store=True, readonly=True)
|
|
|
|
workflow_id = fields.Many2one(comodel_name="soong.workflow")
|
|
node_id = fields.Many2one(comodel_name="soong.workflow.node")
|
|
node_btn_id = fields.Many2one(comodel_name="soong.workflow.node.button", string="动作名称")
|
|
|
|
done_by = fields.Many2one(comodel_name="res.users", string="审批人")
|
|
lase_click_date = fields.Datetime(string="操作时间")
|
|
approval_state = fields.Selection([
|
|
('0', '未审批'),
|
|
('1', '审批中'),
|
|
('2', '审批通过'),
|
|
], string='审批状态', default='0')
|
|
comment = fields.Char(string="意见")
|
|
|
|
@api.depends("workflow_id", "node_id", "node_btn_id")
|
|
def _compute_name(self):
|
|
for rec in self:
|
|
# rec.name = "%(workflow_id_name)s - %(node_id_name)s - %(node_btn_name)s" % {
|
|
# "workflow_id_name": rec.workflow_id.name,
|
|
# "node_id_name": rec.node_id.name,
|
|
# "node_btn_name": rec.node_btn_id.name,
|
|
# }
|
|
rec.name = "%(node_id_name)s" % {"node_id_name": rec.node_id.name}
|