Compute at_warehouse in unit load when reopen load order.

This commit refs #25458


(cherry picked from commit 4049e917b0)
This commit is contained in:
José Miguel Pardo Salar 2023-01-27 14:29:48 +01:00 committed by Sergio Morillo
parent 8a44bcd45c
commit 529e98ce1e
2 changed files with 24 additions and 1 deletions

View File

@ -68,6 +68,7 @@ class LoadOrder(metaclass=PoolMeta):
Move = pool.get('stock.move')
ShipmentOut = pool.get('stock.shipment.out')
ShipmentInternal = pool.get('stock.shipment.internal')
UnitLoad = pool.get('stock.unit_load')
to_run = [r for r in records if r.state == 'done']
if to_run:
@ -94,6 +95,8 @@ class LoadOrder(metaclass=PoolMeta):
if not m.shipment]
order_moves.extend([m for r in to_run for m in r.inventory_moves
if not m.shipment])
uls = list(set(m.unit_load for m in moves + order_moves
if m.unit_load))
with Transaction().set_context(
_check_access=False,
check_origin=False,
@ -109,6 +112,8 @@ class LoadOrder(metaclass=PoolMeta):
Sale.cancel(sales)
if sale_lines:
SaleLine.delete(sale_lines)
if uls:
UnitLoad.set_at_warehouse(uls)
super(LoadOrder, cls).run(records)

View File

@ -462,6 +462,8 @@ Create internal load to check later moves with failure::
>>> unit_load2 = create_unit_load(config=config,
... default_values={'start_date': datetime.datetime.now() - relativedelta(days=1)})
>>> unit_load2.at_warehouse == wh
True
>>> start_load = Wizard('carrier.load_uls', [load_order2])
>>> start_load.form.ul_code = unit_load2.code
@ -472,10 +474,26 @@ Create internal load to check later moves with failure::
1
>>> load_order2.state
'done'
>>> load_order2.shipment.state
'done'
>>> unit_load2.reload()
>>> unit_load2.at_warehouse == wh2
True
>>> load_order2.click('run')
>>> load_order2.shipment.state
'cancelled'
>>> unit_load2.reload()
>>> unit_load2.at_warehouse == wh
True
>>> load_order2.click('do')
>>> load_order2.shipment.state
'done'
>>> unit_load2.reload()
>>> unit_load2.at_warehouse == wh2
True
Add moves to Unit Load::
>>> unit_load2.reload()
>>> move_try = Wizard('stock.unit_load.do_move', [unit_load2])
>>> move_try.form.location = wh.storage_location
>>> move_try.execute('move_')