[FIX] website_sale_aplicoop: freeze pickup dates on cron confirm
This commit is contained in:
parent
331a2e8944
commit
7d11a95344
2 changed files with 68 additions and 1 deletions
|
|
@ -73,7 +73,9 @@ class TestCronPickingBatch(TransactionCase):
|
|||
"group_ids": [
|
||||
(6, 0, [self.consumer_group_1.id, self.consumer_group_2.id])
|
||||
],
|
||||
"period": "once", # One-time order to avoid date recalculation
|
||||
"period": "once", # One-time order; dates are set explicitly below
|
||||
"cutoff_day": "0", # Monday
|
||||
"pickup_day": "2", # Wednesday
|
||||
"state": state,
|
||||
}
|
||||
)
|
||||
|
|
@ -192,6 +194,37 @@ class TestCronPickingBatch(TransactionCase):
|
|||
"Sale order should be confirmed - cutoff date has passed",
|
||||
)
|
||||
|
||||
def test_cron_freezes_pickup_date_on_confirm(self):
|
||||
"""Confirmed orders must keep the cycle pickup date (no next-week drift)."""
|
||||
group_order = self._create_group_order(cutoff_in_past=True)
|
||||
|
||||
so = self._create_sale_order(group_order, self.member_1, self.consumer_group_1)
|
||||
|
||||
self.assertTrue(
|
||||
group_order.pickup_date,
|
||||
"Precondition failed: helper must provide a non-empty pickup_date",
|
||||
)
|
||||
|
||||
# Simulate an inconsistent draft date (e.g. stale or shifted value)
|
||||
wrong_pickup_date = group_order.pickup_date + timedelta(days=7)
|
||||
so.write({"pickup_date": wrong_pickup_date})
|
||||
|
||||
self.assertEqual(so.state, "draft")
|
||||
self.assertEqual(so.pickup_date, wrong_pickup_date)
|
||||
|
||||
expected_pickup_date = group_order.pickup_date
|
||||
|
||||
group_order._confirm_linked_sale_orders()
|
||||
|
||||
so.invalidate_recordset()
|
||||
|
||||
self.assertEqual(so.state, "sale")
|
||||
self.assertEqual(
|
||||
so.pickup_date,
|
||||
expected_pickup_date,
|
||||
"Cron should snapshot and preserve the current cycle pickup_date when confirming",
|
||||
)
|
||||
|
||||
def test_cron_creates_picking_batch_per_consumer_group(self):
|
||||
"""Test that cron creates separate picking batches per consumer group."""
|
||||
# Create group order with cutoff yesterday (past)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue