42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import fields, models
|
|
|
|
|
|
class BpdEdge(models.Model):
|
|
"""流程图连线(流程走向 / 关联流程)。"""
|
|
_name = 'yuthon.bpd.edge'
|
|
_description = '流程连线'
|
|
_order = 'sequence, id'
|
|
|
|
diagram_id = fields.Many2one(
|
|
'yuthon.bpd.diagram', string='流程图', required=True,
|
|
ondelete='cascade', index=True,
|
|
)
|
|
from_id = fields.Many2one(
|
|
'yuthon.bpd.node', string='起点', required=True, ondelete='cascade',
|
|
)
|
|
to_id = fields.Many2one(
|
|
'yuthon.bpd.node', string='终点', required=True, ondelete='cascade',
|
|
)
|
|
label = fields.Char(string='线标签')
|
|
style = fields.Selection(
|
|
[('solid', '实线'), ('dashed', '虚线')],
|
|
string='线型', default='solid', required=True,
|
|
)
|
|
sequence = fields.Integer(default=10)
|
|
|
|
_sql_constraints = [
|
|
('bpd_edge_uniq', 'unique(diagram_id, from_id, to_id)',
|
|
'同一条流程连线不能重复'),
|
|
]
|
|
|
|
def to_json(self):
|
|
self.ensure_one()
|
|
return {
|
|
'id': self.id,
|
|
'from': self.from_id.id,
|
|
'to': self.to_id.id,
|
|
'label': self.label or '',
|
|
'style': self.style,
|
|
}
|