[FIX] website_sale_aplicoop: auto-derive home_delivery from delivery_product_id

Make group.order.home_delivery a computed stored field that is True
whenever delivery_product_id is set, eliminating the manual checkbox
that could be forgotten. This fixes sale.order.home_delivery not being
set when the delivery product was configured but the boolean was left
unchecked.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
GitHub Copilot 2026-05-20 17:37:33 +02:00
parent fb1efb0474
commit 9d614ed79e
2 changed files with 9 additions and 3 deletions

View file

@ -134,7 +134,8 @@ class GroupOrder(models.Model):
# === Home delivery ===
home_delivery = fields.Boolean(
default=False,
compute="_compute_home_delivery",
store=True,
tracking=True,
help="Whether this consumer group order includes home delivery service",
)
@ -255,6 +256,11 @@ class GroupOrder(models.Model):
else:
record.display_image = False
@api.depends("delivery_product_id")
def _compute_home_delivery(self):
for record in self:
record.home_delivery = bool(record.delivery_product_id)
available_products_count = fields.Integer(
compute="_compute_available_products_count",
store=False,