- Add consumer_group_id to sale.order for tracking the consumer group - Fix stock.picking consumer_group_id to use sale_id.consumer_group_id - Add group_ids inverse relation in res.partner for bidirectional access - Remove auto-calculation of consumer_group_id, data comes directly from group_order.group_ids[0] - Add debug logging for consumer_group propagation - commitment_date propagates directly from group_order (no recalculation)
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
# Copyright 2025 Criptomart
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
|
|
|
from odoo import fields
|
|
from odoo import models
|
|
|
|
|
|
class SaleOrder(models.Model):
|
|
_inherit = "sale.order"
|
|
|
|
def _get_pickup_day_selection(self):
|
|
"""Return pickup day selection options with translations."""
|
|
return [
|
|
("0", self.env._("Monday")),
|
|
("1", self.env._("Tuesday")),
|
|
("2", self.env._("Wednesday")),
|
|
("3", self.env._("Thursday")),
|
|
("4", self.env._("Friday")),
|
|
("5", self.env._("Saturday")),
|
|
("6", self.env._("Sunday")),
|
|
]
|
|
|
|
pickup_day = fields.Selection(
|
|
selection=_get_pickup_day_selection,
|
|
help="Day of week when this order will be picked up",
|
|
)
|
|
|
|
group_order_id = fields.Many2one(
|
|
"group.order",
|
|
help="Reference to the consumer group order that originated this sale order",
|
|
)
|
|
|
|
consumer_group_id = fields.Many2one(
|
|
"res.partner",
|
|
domain="[('is_group', '=', True)]",
|
|
help="Consumer group for this order",
|
|
)
|
|
|
|
pickup_date = fields.Date(
|
|
help="Pickup/delivery date",
|
|
)
|
|
|
|
home_delivery = fields.Boolean(
|
|
default=False,
|
|
help="Whether this order includes home delivery",
|
|
)
|
|
|
|
def _get_name_portal_content_view(self):
|
|
"""Override to return custom portal content template with group order info.
|
|
|
|
This method is called by the portal template to determine which content
|
|
template to render. We return our custom template that includes the
|
|
group order information (Consumer Group, Delivery/Pickup info, etc.)
|
|
"""
|
|
self.ensure_one()
|
|
if self.group_order_id:
|
|
return "website_sale_aplicoop.sale_order_portal_content_aplicoop"
|
|
return super()._get_name_portal_content_view()
|