62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import fields, models
|
|
|
|
|
|
class BpdNode(models.Model):
|
|
"""流程图节点(一个业务动作 / 单据 / 角色)。
|
|
|
|
x / y 是节点**中心**坐标,单位与泳道一致。拖动节点时前端只改这两个值,
|
|
所以画布上任何手工微调都能持久化。
|
|
"""
|
|
_name = 'yuthon.bpd.node'
|
|
_description = '流程节点'
|
|
_order = 'sequence, id'
|
|
_rec_name = 'label'
|
|
|
|
diagram_id = fields.Many2one(
|
|
'yuthon.bpd.diagram', string='流程图', required=True,
|
|
ondelete='cascade', index=True,
|
|
)
|
|
lane_id = fields.Many2one(
|
|
'yuthon.bpd.lane', string='所属泳道', ondelete='set null', index=True,
|
|
)
|
|
label = fields.Char(string='名称', required=True)
|
|
sub = fields.Char(string='副标题', help='节点下方的小字,如「批次」')
|
|
x = fields.Integer(string='X', default=0)
|
|
y = fields.Integer(string='Y', default=0)
|
|
w = fields.Integer(string='宽', default=96)
|
|
h = fields.Integer(string='高', default=34)
|
|
shape = fields.Selection(
|
|
[('box', '矩形'), ('diamond', '菱形'), ('pill', '圆角胶囊'), ('text', '纯文字')],
|
|
string='形状', default='box', required=True,
|
|
)
|
|
variant = fields.Selection(
|
|
[
|
|
('doc', '普通单据'),
|
|
('start', '起点 / 外部角色'),
|
|
('primary', '核心(仓库 / 财务)'),
|
|
('gateway', '判断(核销)'),
|
|
('ghost', '虚化(任务池)'),
|
|
],
|
|
string='样式', default='doc', required=True,
|
|
)
|
|
sequence = fields.Integer(default=10)
|
|
note = fields.Text(string='说明')
|
|
|
|
edge_out_ids = fields.One2many('yuthon.bpd.edge', 'from_id', string='出线')
|
|
edge_in_ids = fields.One2many('yuthon.bpd.edge', 'to_id', string='入线')
|
|
|
|
def to_json(self):
|
|
self.ensure_one()
|
|
return {
|
|
'id': self.id,
|
|
'lane_id': self.lane_id.id or None,
|
|
'lane': self.lane_id.name or '',
|
|
'label': self.label or '',
|
|
'sub': self.sub or '',
|
|
'x': self.x, 'y': self.y, 'w': self.w, 'h': self.h,
|
|
'shape': self.shape,
|
|
'variant': self.variant,
|
|
'note': self.note or '',
|
|
}
|