28 lines
975 B
Python
28 lines
975 B
Python
from odoo import fields, models, api
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class EductionClassGroup(models.Model):
|
|
_name = "education.class.group"
|
|
_description = "Education Class Group"
|
|
_order = "sequence"
|
|
sequence = fields.Integer(string="Sequence", default=0)
|
|
name = fields.Char(string="Name", translate=True, required=True)
|
|
parent_id = fields.Many2one(
|
|
"education.class.group", string="Parent Group", ondelete="restrict"
|
|
)
|
|
child_ids = fields.One2many(
|
|
"education.class.group", "parent_id", string="Child Groups"
|
|
)
|
|
_parent_store = True
|
|
_parent_name = "parent_id"
|
|
parent_path = fields.Char(index=True)
|
|
class_ids = fields.One2many(
|
|
"education.class", "class_group_id", string="Class of Groups"
|
|
)
|
|
|
|
@api.constrains("parent_id")
|
|
def _check_hierarchy(self):
|
|
if not self._check_recursion():
|
|
raise ValidationError("Error! You cannot create recursivecategories.")
|