[FIX] website_sale_aplicoop: harden group order cron
This commit is contained in:
parent
813c8071d9
commit
331a2e8944
4 changed files with 126 additions and 70 deletions
|
|
@ -566,3 +566,49 @@ class TestDateCalculations(TransactionCase):
|
|||
order.pickup_date,
|
||||
f"Pickup date should be set for active order {order.name}",
|
||||
)
|
||||
|
||||
def test_cron_update_dates_skips_orders_without_cutoff_date(self):
|
||||
"""Cron should not crash if an active order lacks cutoff_date.
|
||||
|
||||
A malformed or partially configured active group order should be logged
|
||||
and skipped for sale-order confirmation, but must not block recomputing
|
||||
the rest of active orders.
|
||||
"""
|
||||
today = fields.Date.today()
|
||||
|
||||
valid_order = self.env["group.order"].create(
|
||||
{
|
||||
"name": "Valid Cron Order",
|
||||
"group_ids": [(6, 0, [self.group.id])],
|
||||
"start_date": today,
|
||||
"pickup_day": "2", # Wednesday
|
||||
"cutoff_day": "0", # Monday
|
||||
"period": "weekly",
|
||||
"state": "open",
|
||||
}
|
||||
)
|
||||
invalid_order = self.env["group.order"].create(
|
||||
{
|
||||
"name": "Invalid Cron Order Without Cutoff",
|
||||
"group_ids": [(6, 0, [self.group.id])],
|
||||
"start_date": today,
|
||||
"pickup_day": "2", # Wednesday
|
||||
"cutoff_day": False,
|
||||
"period": "weekly",
|
||||
"state": "open",
|
||||
}
|
||||
)
|
||||
|
||||
self.assertFalse(
|
||||
invalid_order.cutoff_date,
|
||||
"Precondition failed: invalid order should not have cutoff_date",
|
||||
)
|
||||
|
||||
self.env["group.order"]._cron_update_dates()
|
||||
|
||||
valid_order.invalidate_recordset()
|
||||
invalid_order.invalidate_recordset()
|
||||
|
||||
self.assertTrue(valid_order.cutoff_date)
|
||||
self.assertTrue(valid_order.pickup_date)
|
||||
self.assertFalse(invalid_order.cutoff_date)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue