Skip to content

Commit

Permalink
shipment_advice: do not copy shipment advice id on moves
Browse files Browse the repository at this point in the history
In the case of partially receiving goods, the backorder moves created
should not be included in the shipment advice being processed.
But it probably makes sense for outgoing move as well.
  • Loading branch information
TDu committed May 14, 2024
1 parent e45b246 commit fd17878
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions shipment_advice/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class StockMove(models.Model):
ondelete="set null",
string="Planned shipment",
index=True,
copy=False,
)

def _plan_in_shipment(self, shipment_advice):
Expand Down
1 change: 1 addition & 0 deletions shipment_advice/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class StockMoveLine(models.Model):
ondelete="set null",
string="Shipment advice",
index=True,
copy=False,
)

def button_load_in_shipment(self):
Expand Down
20 changes: 20 additions & 0 deletions shipment_advice/tests/test_shipment_advice.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,23 @@ def test_shipment_advice_draft(self):
def test_shipment_name(self):
self.assertTrue("OUT" in self.shipment_advice_out.name)
self.assertTrue("IN" in self.shipment_advice_in.name)

def test_shipment_advice_receive_partial_move_backorder(self):
picking = self.move_product_in1.picking_id
# Plan a move
self._plan_records_in_shipment(self.shipment_advice_in, self.move_product_in1)
self._in_progress_shipment_advice(self.shipment_advice_in)
# Partially receive the move and create a backorder
for ml in self.move_product_in1.move_line_ids:
ml.qty_done = ml.product_uom_qty - 2
wizard = (
self.env["stock.backorder.confirmation"]
.with_context(button_validate_picking_ids=picking.ids)
.create({"pick_ids": [(6, 0, picking.ids)]})
)
wizard.process()
# New move created should not be included in the processing shipment
backorder_picking = self.env["stock.picking"].search(
[("backorder_id", "=", picking.id)]
)
self.assertFalse(backorder_picking.move_lines.shipment_advice_id)

0 comments on commit fd17878

Please sign in to comment.