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

from odoo import fields
from odoo import models


class StockPicking(models.Model):
    _inherit = "stock.picking"

    group_order_id = fields.Many2one(
        "group.order",
        related="sale_id.group_order_id",
        string="Consumer Group Order",
        store=True,
        readonly=True,
        help="Consumer group order from the related sale order",
    )

    home_delivery = fields.Boolean(
        related="sale_id.home_delivery",
        string="Home Delivery",
        store=True,
        readonly=True,
        help="Whether this picking includes home delivery (from sale order)",
    )

    pickup_date = fields.Date(
        related="sale_id.pickup_date",
        string="Pickup Date",
        store=True,
        readonly=True,
        help="Pickup/delivery date from sale order",
    )

    pickup_slot_label = fields.Char(
        related="sale_id.pickup_slot_label",
        string="Pickup Slot",
        store=True,
        readonly=True,
        help="Human readable pickup slot label from the related sale order",
    )

    consumer_group_id = fields.Many2one(
        "res.partner",
        related="sale_id.consumer_group_id",
        string="Consumer Group",
        store=True,
        readonly=True,
        domain=[("is_group", "=", True)],
        help="Consumer group (res.partner with is_group=True) from sale order",
    )
