"""Tombstone record written when a user exercises the right-to-erasure.

We cannot hard-delete the original res.users row (ORM FK constraints on
attempts, tickets, audit trail, etc.), so this table lets us prove the
request happened, what was anonymised/deleted, and when.
"""

from odoo import fields, models


class EncoachGdprErasureRequest(models.Model):
    _name = "encoach.gdpr.erasure.request"
    _description = "GDPR right-to-erasure audit trail"
    _order = "create_date desc"

    user_login = fields.Char(required=True, index=True)
    user_email = fields.Char(index=True)
    user_id_archived = fields.Integer(
        index=True,
        help="Id of the res.users row at time of erasure (row is now archived).",
    )
    status = fields.Selection(
        [
            ("requested", "Requested"),
            ("completed", "Completed"),
            ("partial", "Partial — manual follow-up required"),
        ],
        default="requested", required=True,
    )
    summary = fields.Text(
        help="JSON summary of what was deleted/anonymised/retained.",
    )
    requested_at = fields.Datetime(default=fields.Datetime.now)
    completed_at = fields.Datetime()
    notes = fields.Text()
