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
25 lines
707 B
Python
25 lines
707 B
Python
from odoo import fields, models
|
|
|
|
|
|
class EncoachDiscount(models.Model):
|
|
_name = "encoach.discount"
|
|
_description = "EnCoach Discount Code"
|
|
code = fields.Char(required=True, index=True)
|
|
|
|
_code_unique = models.Constraint(
|
|
"UNIQUE(code)",
|
|
"Discount code must be unique.",
|
|
)
|
|
percentage = fields.Float(digits=(5, 2))
|
|
expiry_date = fields.Datetime()
|
|
max_uses = fields.Integer()
|
|
uses = fields.Integer(default=0)
|
|
|
|
def is_valid(self):
|
|
self.ensure_one()
|
|
if self.max_uses and self.uses >= self.max_uses:
|
|
return False
|
|
if self.expiry_date and self.expiry_date < fields.Datetime.now():
|
|
return False
|
|
return True
|