# -*- coding: utf-8 -*-
from odoo import api, fields, models


class FamilyLawIssue(models.Model):
    _name = "familylaw.issue"
    _description = "Contested Issue"
    _order = "issue_type"

    case_id = fields.Many2one(
        "familylaw.case",
        required=True,
        ondelete="cascade",
        index=True,
    )
    issue_type = fields.Selection(
        selection=[
            ("time_sharing", "Time-Sharing / Parental Responsibility"),
            ("child_support", "Child Support"),
            ("equitable_distribution", "Equitable Distribution"),
            ("alimony", "Alimony / Spousal Support"),
            ("attorneys_fees", "Attorney's Fees"),
            ("other", "Other"),
        ],
        string="Issue",
        required=True,
    )
    name = fields.Char(
        compute="_compute_name",
        store=True,
        string="Issue Label",
    )
    description = fields.Text()

    @api.depends("issue_type")
    def _compute_name(self):
        labels = dict(self._fields["issue_type"].selection)
        for issue in self:
            issue.name = labels.get(issue.issue_type, "")
