Files
encoach_be_odoo19/encoach_exam/models/approval_workflow.py
Talal Sharabi f5b627256f 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
2026-03-14 16:46:46 +04:00

59 lines
1.9 KiB
Python

from odoo import models, fields
WORKFLOW_STATUS = [
("pending", "Pending"),
("approved", "Approved"),
("rejected", "Rejected"),
]
class EncoachApprovalWorkflow(models.Model):
_name = "encoach.approval.workflow"
_description = "EnCoach Exam Approval Workflow"
exam_id = fields.Many2one("encoach.exam", ondelete="cascade", index=True)
creator_id = fields.Many2one("res.users", default=lambda self: self.env.uid)
entity_id = fields.Many2one("encoach.entity")
name = fields.Char()
modules = fields.Json(help='List of modules, e.g. ["reading","writing"]')
steps = fields.Json(
help="Array of workflow step objects with stepType, stepNumber, "
"completed, rejected, completedBy, assignees, etc.",
)
status = fields.Selection(WORKFLOW_STATUS, default="pending", required=True)
start_date = fields.Datetime(default=fields.Datetime.now)
legacy_id = fields.Char(index=True)
def action_approve(self):
for rec in self:
rec.status = "approved"
if rec.exam_id:
rec.exam_id.approved = True
def action_reject(self):
for rec in self:
rec.status = "rejected"
if rec.exam_id:
rec.exam_id.approved = False
def action_reset(self):
for rec in self:
rec.status = "pending"
def to_encoach_dict(self):
self.ensure_one()
return {
"id": self.id,
"name": self.name or "",
"entityId": self.entity_id.id if self.entity_id else None,
"requester": self.creator_id.id if self.creator_id else None,
"startDate": (
int(self.start_date.timestamp() * 1000)
if self.start_date else None
),
"modules": self.modules or [],
"examId": self.exam_id.id if self.exam_id else None,
"status": self.status,
"steps": self.steps or [],
}