Full backend implementation with custom Odoo modules: - encoach_api: Core API, user management, JWT auth - encoach_exam: Exam generation (reading, writing, listening, speaking) - encoach_evaluate: AI-powered evaluation (writing, speaking) - encoach_training: Training tips and walkthrough - encoach_storage: File storage management - encoach_payment: Stripe, PayPal, Paymob integration - encoach_mail: Email notifications Made-with: Cursor
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from odoo import models, fields
|
|
|
|
|
|
class EncoachGroup(models.Model):
|
|
_name = "encoach.group"
|
|
_description = "EnCoach Classroom Group"
|
|
|
|
name = fields.Char(required=True)
|
|
admin_id = fields.Many2one("res.users", string="Admin", required=True)
|
|
participant_ids = fields.Many2many(
|
|
"res.users", "encoach_group_participant_rel", "group_id", "user_id",
|
|
string="Participants",
|
|
)
|
|
disable_editing = fields.Boolean(default=False)
|
|
entity_id = fields.Many2one("encoach.entity", index=True)
|
|
legacy_id = fields.Char(index=True)
|
|
participant_count = fields.Integer(
|
|
string="Participants",
|
|
compute="_compute_participant_count",
|
|
store=False,
|
|
)
|
|
|
|
def _compute_participant_count(self):
|
|
for rec in self:
|
|
rec.participant_count = len(rec.participant_ids)
|
|
|
|
def to_encoach_dict(self):
|
|
self.ensure_one()
|
|
return {
|
|
"id": self.id,
|
|
"name": self.name,
|
|
"admin": self.admin_id.id,
|
|
"participants": self.participant_ids.ids,
|
|
"disableEditing": self.disable_editing,
|
|
"entity": self.entity_id.id if self.entity_id else None,
|
|
}
|