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
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from odoo import models, fields
|
|
|
|
|
|
class EncoachEntity(models.Model):
|
|
_name = "encoach.entity"
|
|
_description = "EnCoach Entity (Organization)"
|
|
_inherit = ["mail.thread"]
|
|
|
|
name = fields.Char(required=True, tracking=True)
|
|
label = fields.Char()
|
|
licenses = fields.Integer(default=0)
|
|
expiry_date = fields.Datetime()
|
|
payment_currency = fields.Char()
|
|
payment_price = fields.Float(digits=(12, 2))
|
|
role_ids = fields.One2many("encoach.role", "entity_id", string="Roles")
|
|
user_rel_ids = fields.One2many(
|
|
"encoach.user.entity.rel", "entity_id", string="Members",
|
|
)
|
|
legacy_id = fields.Char(index=True)
|
|
|
|
def to_encoach_dict(self):
|
|
self.ensure_one()
|
|
payment = None
|
|
if self.payment_currency and self.payment_price:
|
|
payment = {
|
|
"currency": self.payment_currency,
|
|
"price": self.payment_price,
|
|
}
|
|
return {
|
|
"id": self.id,
|
|
"label": self.label or self.name,
|
|
"licenses": self.licenses,
|
|
"expiryDate": (
|
|
self.expiry_date.isoformat() if self.expiry_date else None
|
|
),
|
|
"payment": payment,
|
|
}
|