# Copyright 2025-Today Criptomart
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import fields
from odoo import models

# Note: translation function _ is not used in this module (removed to satisfy flake8)


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

    # Campo para identificar si un partner es un grupo
    is_group = fields.Boolean(
        string="Is a Consumer Group?",
        help="Check this box if the partner represents a group of users",
        default=False,
    )

    # Relación para los miembros de un grupo (si is_group es True)
    member_ids = fields.Many2many(
        "res.partner",
        "res_partner_group_members_rel",
        "group_id",
        "member_id",
        domain=[("is_group", "=", True)],
        string="Consumer Groups",
        help="Consumer Groups this partner belongs to",
    )

    # Inverse relation: group orders this group participates in
    group_order_ids = fields.Many2many(
        "group.order",
        "group_order_group_rel",
        "group_id",
        "order_id",
        string="Consumer Group Orders",
        help="Group orders this consumer group participates in",
        readonly=True,
    )
