# -*- coding: utf-8 -*-

from odoo import fields, models


class FusionPdfPreviewLog(models.Model):
    _name = 'fusion.pdf.preview.log'
    _description = 'PDF Preview Audit Log'
    _order = 'create_date desc'
    _rec_name = 'report_name'

    user_id = fields.Many2one(
        'res.users', string='User',
        required=True, default=lambda self: self.env.uid,
        index=True,
    )
    report_id = fields.Many2one(
        'ir.actions.report', string='Report',
        ondelete='set null', index=True,
    )
    report_name = fields.Char(
        string='Report Name', required=True,
        help='Stored report name for reference even if the report is later deleted.',
    )
    action_type = fields.Selection([
        ('preview', 'Preview'),
        ('print', 'Print'),
        ('download', 'Download'),
    ], string='Action', required=True, index=True)
    record_ids = fields.Char(
        string='Record IDs',
        help='Comma-separated list of record IDs included in the report.',
    )
    model_name = fields.Char(
        string='Model',
        help='Technical model name of the records.',
    )
