[IMP] website_sale_aplicoop: simplify cutoff guard in _confirm_linked_sale_orders
All group orders have cutoff configured; stale orders are already closed/cancelled. Single guard: skip if cutoff_date >= today (cycle still open).
This commit is contained in:
parent
7fc42625a3
commit
12d434d4c7
1 changed files with 1 additions and 26 deletions
|
|
@ -669,17 +669,7 @@ class GroupOrder(models.Model):
|
|||
|
||||
today = fields.Date.today()
|
||||
|
||||
# Skip if no cutoff date - without a cutoff_day there is no weekly cycle
|
||||
# to close automatically (would confirm ALL draft orders indiscriminately)
|
||||
if not self.cutoff_date:
|
||||
_logger.info(
|
||||
"Cron: Skipping group order %s (%s) - no cutoff_date configured",
|
||||
self.id,
|
||||
self.name,
|
||||
)
|
||||
return
|
||||
|
||||
# Skip if cutoff hasn't passed yet (the day is still open for orders)
|
||||
# Skip if cutoff hasn't passed yet (the cycle is still open for orders)
|
||||
if self.cutoff_date >= today:
|
||||
_logger.info(
|
||||
"Cron: Skipping group order %s (%s) - cutoff date %s not yet passed",
|
||||
|
|
@ -689,21 +679,6 @@ class GroupOrder(models.Model):
|
|||
)
|
||||
return
|
||||
|
||||
# Skip if cutoff was 7+ days ago: it belongs to an already-processed cycle.
|
||||
# This guards against stale stored dates (e.g. cron was down for several days)
|
||||
# and prevents confirming orders that were just created for the NEW cycle.
|
||||
days_since_cutoff = (today - self.cutoff_date).days
|
||||
if days_since_cutoff >= 7:
|
||||
_logger.info(
|
||||
"Cron: Skipping group order %s (%s) - cutoff date %s is stale "
|
||||
"(%d days ago, already processed)",
|
||||
self.id,
|
||||
self.name,
|
||||
self.cutoff_date,
|
||||
days_since_cutoff,
|
||||
)
|
||||
return
|
||||
|
||||
SaleOrder = self.env["sale.order"].sudo()
|
||||
sale_orders = SaleOrder.search(
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue