From ac002946237b7cab82efff657271cd1147b18442 Mon Sep 17 00:00:00 2001 From: snt Date: Mon, 30 Mar 2026 19:14:02 +0200 Subject: [PATCH] [FIX] website_sale_aplicoop: fix auto-confirm sale.order on cutoff day - _cron_update_dates: call _confirm_linked_sale_orders() BEFORE recomputing dates so cutoff_date still points to the current cycle when the check runs - _confirm_linked_sale_orders: change >= to > so orders are confirmed both on the cutoff day itself and after it has passed --- website_sale_aplicoop/models/group_order.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/website_sale_aplicoop/models/group_order.py b/website_sale_aplicoop/models/group_order.py index 9c63af4..bb9b02a 100644 --- a/website_sale_aplicoop/models/group_order.py +++ b/website_sale_aplicoop/models/group_order.py @@ -647,10 +647,13 @@ class GroupOrder(models.Model): orders = self.search([("state", "in", ["draft", "open"])]) _logger.info("Cron: Updating dates for %d active group orders", len(orders)) for order in orders: + # Confirm BEFORE recomputing dates: cutoff_date still points to the + # current cycle's cutoff (today or past), so the check works correctly. + # After confirmation, recompute dates so they advance to the next cycle. + order._confirm_linked_sale_orders() order._compute_cutoff_date() order._compute_pickup_date() order._compute_delivery_date() - order._confirm_linked_sale_orders() _logger.info("Cron: Date update completed") def _confirm_linked_sale_orders(self): @@ -664,9 +667,9 @@ class GroupOrder(models.Model): """ self.ensure_one() - # Only confirm if cutoff date has passed + # Only confirm if cutoff date has reached or passed (>= cutoff day itself) today = fields.Date.today() - if self.cutoff_date and self.cutoff_date >= today: + if self.cutoff_date and self.cutoff_date > today: _logger.info( "Cron: Skipping group order %s (%s) - cutoff date %s not yet passed", self.id,