# © 2020 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ResPartner(models.Model):
    _inherit = "res.partner"

    contribution_report_ids = fields.One2many(
        comodel_name="scop.contribution.report",
        inverse_name="partner_id",
        string="Cotisations",
    )

    def get_partner_contribution_type(self):
        """
        Returns list of contribution type for partner
        """
        contribution_type = [self.env.ref("cgscop_partner.riga_14397")]
        if self.ur_id in [
            self.env.ref("cgscop_partner.riga_14232"),
            self.env.ref("cgscop_partner.riga_14243"),
            self.env.ref("cgscop_partner.riga_14231"),
        ]:
            contribution_type.append(self.env.ref("cgscop_partner.riga_14399"))
        if self.is_federation_com:
            contribution_type.append(self.env.ref("cgscop_partner.riga_14398"))
        # TODO: Mettre à jour avec is_federation_cae après la maj des périodes par la CG
        if self.cae:
            contribution_type.append(self.env.ref("cgscop_partner.cotiz_fede_cae"))
        if self.is_federation_indus:
            contribution_type.append(self.env.ref("cgscop_partner.cotiz_fede_indus"))
        return contribution_type