Skip to content

Commit

Permalink
fixup! shipment_advice: do not copy shipment advice id on moves
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu committed Jul 11, 2024
1 parent fd17878 commit 46152a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions shipment_advice/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ class StockMove(models.Model):
def _plan_in_shipment(self, shipment_advice):
"""Plan the moves into the given shipment advice."""
self.shipment_advice_id = shipment_advice

def _prepare_move_split_vals(self, qty):
vals = super()._prepare_move_split_vals(qty)
if self.env.context.get("shipment_advice__propagate_on_split"):
vals.update(shipment_advice_id=self.shipment_advice_id.id)
return vals
14 changes: 14 additions & 0 deletions shipment_advice/tests/test_shipment_advice.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,17 @@ def test_shipment_advice_receive_partial_move_backorder(self):
[("backorder_id", "=", picking.id)]
)
self.assertFalse(backorder_picking.move_lines.shipment_advice_id)

def test_move_split_propagation(self):
"""Check the use of conext key to propagate the shipment id on move split."""
move = self.move_product_in1
self._plan_records_in_shipment(self.shipment_advice_in, move)
self.assertTrue(move.shipment_advice_id)
# Without the context key the shipment advice id is not copied
vals = move._prepare_move_split_vals(1)
self.assertTrue("shipemnt_advice_id" not in vals.keys())
# But it is with the context key
vals = move.with_context(
shipment_advice__propagate_on_split=True
)._prepare_move_split_vals(1)
self.assertTrue("shipment_advice_id" in vals.keys())

0 comments on commit 46152a5

Please sign in to comment.