2025-02-22 10:32:13 +07:00
|
|
|
from odoo import fields, models, api
|
|
|
|
|
from odoo.exceptions import ValidationError
|
2025-02-21 18:00:17 +07:00
|
|
|
|
2025-02-22 12:10:53 +07:00
|
|
|
|
2025-02-26 16:28:17 +07:00
|
|
|
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"
|
|
|
|
|
)
|
2025-02-22 10:32:13 +07:00
|
|
|
_parent_store = True
|
|
|
|
|
_parent_name = "parent_id"
|
|
|
|
|
parent_path = fields.Char(index=True)
|
2025-02-26 16:28:17 +07:00
|
|
|
class_ids = fields.One2many(
|
|
|
|
|
"education.class", "class_group_id", string="Class of Groups"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@api.constrains("parent_id")
|
2025-02-22 10:32:13 +07:00
|
|
|
def _check_hierarchy(self):
|
|
|
|
|
if not self._check_recursion():
|
2025-02-26 16:28:17 +07:00
|
|
|
raise ValidationError("Error! You cannot create recursivecategories.")
|