from odoo import models, fields


class EncoachAiGenerationLog(models.Model):
    _name = 'encoach.ai.generation.log'
    _description = 'AI Generation Log'

    student_id = fields.Many2one('res.users', ondelete='set null')
    course_type = fields.Selection([
        ('general_english', 'General English'),
        ('ielts', 'IELTS'),
    ], required=True)
    brief = fields.Text()
    attempts = fields.Integer(default=0)
    final_resource_id = fields.Integer(string='Final Resource ID')
    approved_by = fields.Many2one('res.users', ondelete='set null')
    status = fields.Selection([
        ('generating', 'Generating'),
        ('quality_check', 'Quality Check'),
        ('pending_review', 'Pending Review'),
        ('approved', 'Approved'),
        ('rejected', 'Rejected'),
    ], default='generating', required=True)
    created_at = fields.Datetime(default=fields.Datetime.now)
    error_log = fields.Text()
