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 12, 2024
1 parent 90effa8 commit 5a708af
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 @@ -24,3 +24,9 @@ def _prepare_merge_moves_distinct_fields(self):
# Avoid having stock move assign to different shipment merged together
res.append("shipment_advice_id")
return res

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 5a708af

Please sign in to comment.