[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
|
|
@ -765,6 +765,40 @@ class GroupOrder(models.Model):
|
|||
)
|
||||
|
||||
try:
|
||||
# Freeze cycle dates in sale orders BEFORE confirming and BEFORE
|
||||
# group order dates are recomputed by the cron caller.
|
||||
# This avoids displaying next cycle dates in already confirmed orders.
|
||||
pickup_orders = sale_orders.filtered(lambda so: not so.home_delivery)
|
||||
delivery_orders = sale_orders.filtered(lambda so: so.home_delivery)
|
||||
|
||||
if pickup_orders:
|
||||
pickup_orders.write(
|
||||
{
|
||||
"pickup_day": self.pickup_day,
|
||||
"pickup_date": self.pickup_date,
|
||||
"commitment_date": self.pickup_date,
|
||||
}
|
||||
)
|
||||
|
||||
if delivery_orders:
|
||||
delivery_commitment_date = self.delivery_date or self.pickup_date
|
||||
delivery_orders.write(
|
||||
{
|
||||
"pickup_day": self.pickup_day,
|
||||
"pickup_date": self.pickup_date,
|
||||
"commitment_date": delivery_commitment_date,
|
||||
}
|
||||
)
|
||||
|
||||
_logger.info(
|
||||
"Cron: Snapshot dates applied to %d sale orders for group order %s (%s): pickup_date=%s, delivery_date=%s",
|
||||
len(sale_orders),
|
||||
self.id,
|
||||
self.name,
|
||||
self.pickup_date,
|
||||
self.delivery_date,
|
||||
)
|
||||
|
||||
sale_orders.action_confirm()
|
||||
# Create picking batches after confirmation
|
||||
self._create_picking_batches_for_sale_orders(sale_orders)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue