EnCoach Odoo 19 custom modules
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
This commit is contained in:
3
encoach_subscription/models/__init__.py
Normal file
3
encoach_subscription/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from . import package
|
||||
from . import subscription_payment
|
||||
from . import discount
|
||||
24
encoach_subscription/models/discount.py
Normal file
24
encoach_subscription/models/discount.py
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
25
encoach_subscription/models/package.py
Normal file
25
encoach_subscription/models/package.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class EncoachPackage(models.Model):
|
||||
_name = "encoach.package"
|
||||
_description = "EnCoach Subscription Package"
|
||||
|
||||
name = fields.Char(required=True)
|
||||
price = fields.Float(digits=(12, 2))
|
||||
currency = fields.Char(default="USD")
|
||||
duration_days = fields.Integer()
|
||||
features = fields.Json()
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
def to_encoach_dict(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"price": self.price,
|
||||
"currency": self.currency or "USD",
|
||||
"durationDays": self.duration_days,
|
||||
"features": self.features,
|
||||
"active": self.active,
|
||||
}
|
||||
35
encoach_subscription/models/subscription_payment.py
Normal file
35
encoach_subscription/models/subscription_payment.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class EncoachSubscriptionPayment(models.Model):
|
||||
_name = "encoach.subscription.payment"
|
||||
_description = "EnCoach Subscription Payment"
|
||||
|
||||
user_id = fields.Many2one("res.users", string="User", ondelete="set null")
|
||||
package_id = fields.Many2one(
|
||||
"encoach.package", string="Package", ondelete="set null",
|
||||
)
|
||||
provider = fields.Selection(
|
||||
[
|
||||
("stripe", "Stripe"),
|
||||
("paypal", "PayPal"),
|
||||
("paymob", "Paymob"),
|
||||
],
|
||||
string="Payment Provider",
|
||||
)
|
||||
status = fields.Selection(
|
||||
[
|
||||
("pending", "Pending"),
|
||||
("completed", "Completed"),
|
||||
("failed", "Failed"),
|
||||
],
|
||||
default="pending",
|
||||
)
|
||||
amount = fields.Float(digits=(12, 2))
|
||||
currency = fields.Char()
|
||||
transaction_id = fields.Char(index=True)
|
||||
created_at = fields.Datetime(default=fields.Datetime.now)
|
||||
entity_id = fields.Many2one(
|
||||
"encoach.entity", string="Entity", ondelete="set null",
|
||||
)
|
||||
legacy_id = fields.Char(index=True)
|
||||
Reference in New Issue
Block a user