Files
tryton/trytond/tests/mptt.py
T

31 lines
1009 B
Python

#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
"Test for Tree"
from trytond.osv import fields, OSV
class MPTT(OSV):
'Modified Preorder Tree Traversal'
_name = 'tests.mptt'
_description = __doc__
name = fields.Char('Name', required=True)
sequence = fields.Integer('Sequence')
parent = fields.Many2One('tests.mptt', "Parent", select=1,
left="left", right="right")
left = fields.Integer('Left', required=True, select=1)
right = fields.Integer('Right', required=True, select=1)
childs = fields.One2Many('tests.mptt', 'parent', 'Childs')
def __init__(self):
super(MPTT, self).__init__()
self._order.insert(0, ('sequence', 'ASC'))
self._constraints += [
('check_recursion', 'recursive_mptt'),
]
self._error_messages.update({
'recursive_mptt': 'You can not create recursive Tree!',
})
MPTT()