[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
This commit is contained in:
parent
7e13ffef07
commit
ac00294623
1 changed files with 6 additions and 3 deletions
|
|
@ -647,10 +647,13 @@ class GroupOrder(models.Model):
|
||||||
orders = self.search([("state", "in", ["draft", "open"])])
|
orders = self.search([("state", "in", ["draft", "open"])])
|
||||||
_logger.info("Cron: Updating dates for %d active group orders", len(orders))
|
_logger.info("Cron: Updating dates for %d active group orders", len(orders))
|
||||||
for order in 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_cutoff_date()
|
||||||
order._compute_pickup_date()
|
order._compute_pickup_date()
|
||||||
order._compute_delivery_date()
|
order._compute_delivery_date()
|
||||||
order._confirm_linked_sale_orders()
|
|
||||||
_logger.info("Cron: Date update completed")
|
_logger.info("Cron: Date update completed")
|
||||||
|
|
||||||
def _confirm_linked_sale_orders(self):
|
def _confirm_linked_sale_orders(self):
|
||||||
|
|
@ -664,9 +667,9 @@ class GroupOrder(models.Model):
|
||||||
"""
|
"""
|
||||||
self.ensure_one()
|
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()
|
today = fields.Date.today()
|
||||||
if self.cutoff_date and self.cutoff_date >= today:
|
if self.cutoff_date and self.cutoff_date > today:
|
||||||
_logger.info(
|
_logger.info(
|
||||||
"Cron: Skipping group order %s (%s) - cutoff date %s not yet passed",
|
"Cron: Skipping group order %s (%s) - cutoff date %s not yet passed",
|
||||||
self.id,
|
self.id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue