diff --git a/CHANGELOG b/CHANGELOG index 3d911acc67..b6997119ab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow to change the destination of internal shipment's moves * Allow to modify internal shipment moves in waiting state * Compute inventory lines in complete_lines() using new grouping() method * Allow to re-compute cost price diff --git a/shipment.py b/shipment.py index 2831b28b1d..530e17b053 100644 --- a/shipment.py +++ b/shipment.py @@ -1784,9 +1784,15 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView): | ~Eval('from_location') | ~Eval('to_location')), }, domain=[ - ('from_location', 'child_of', [Eval('from_location', -1)], - 'parent'), - ('to_location', '=', Eval('to_location')), + If(Eval('state') == 'draft', [ + ('from_location', '=', Eval('from_location')), + ('to_location', '=', Eval('to_location')), + ], [ + ('from_location', 'child_of', [Eval('from_location', -1)], + 'parent'), + ('to_location', 'child_of', [Eval('to_location', -1)], + 'parent'), + ]), ('company', '=', Eval('company')), ], depends=['state', 'from_location', 'to_location', 'planned_date', @@ -1933,13 +1939,6 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView): @ModelView.button @Workflow.transition('draft') def draft(cls, shipments): - Move = Pool().get('stock.move') - Move.draft([m for s in shipments for m in s.moves]) - - @classmethod - @ModelView.button - @Workflow.transition('waiting') - def wait(cls, shipments): Move = Pool().get('stock.move') # First reset state to draft to allow update from and to location Move.draft([m for s in shipments for m in s.moves]) @@ -1951,6 +1950,20 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView): 'planned_date': shipment.planned_date, }) + @classmethod + @ModelView.button + @Workflow.transition('waiting') + def wait(cls, shipments): + Move = Pool().get('stock.move') + Move.draft([m for s in shipments for m in s.moves]) + moves = [] + for shipment in shipments: + for move in shipment.moves: + if move.state != 'done': + move.planned_date = shipment.planned_date + moves.append(move) + Move.save(moves) + @classmethod @Workflow.transition('assigned') def assign(cls, shipments):