Skip to content

Commit

Permalink
[17.0][MIG] stock_auto_move
Browse files Browse the repository at this point in the history
  • Loading branch information
ferran-S73 committed Dec 19, 2024
1 parent a351b07 commit bbf0e71
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 39 deletions.
2 changes: 1 addition & 1 deletion stock_auto_move/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Automatic Move Processing",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "NDP Systèmes, ACSONE SA/NV, Odoo Community Association (OCA)",
"category": "Warehouse",
"development_status": "Production/Stable",
Expand Down
17 changes: 1 addition & 16 deletions stock_auto_move/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class StockMove(models.Model):

def _auto_assign_quantities(self):
for move in self:
move.quantity_done = move.reserved_availability
move.picked = True

def _action_assign(self, force_qty=False):
res = super()._action_assign(force_qty=force_qty)
Expand All @@ -34,21 +34,6 @@ def _action_assign(self, force_qty=False):
moves.mapped("picking_id")._create_backorder()
return res

@api.model
def _get_auto_moves_by_pickings(self, auto_moves):
"""Group moves by picking.
@param auto_moves: stock.move data set
@return dict dict of moves grouped by pickings
{stock.picking(id): stock.move(id1, id2, id3 ...), ...}
"""
auto_moves_by_pickings = dict()
for move in auto_moves:
if move.picking_id in auto_moves_by_pickings:
auto_moves_by_pickings[move.picking_id] |= move
else:
auto_moves_by_pickings.update({move.picking_id: move})
return auto_moves_by_pickings

def _change_procurement_group(self):
automatic_group = self.env.ref("stock_auto_move.automatic_group")
moves = self.filtered(lambda m: m.auto_move and not m.group_id)
Expand Down
42 changes: 20 additions & 22 deletions stock_auto_move/tests/test_stock_auto_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ def test_10_auto_move(self):
}
)
move3._action_confirm()
self.env["stock.quant"]._update_available_quantity(
self.product_a1232, self.location_shelf, 25, 0
)
move3._action_assign()
move3.quantity_done = move3.product_qty
move3.picked = True
move3._action_done()
move._action_assign()
move2._action_assign()
Expand Down Expand Up @@ -195,7 +198,7 @@ def test_40_chained_auto_move(self):
picking.action_confirm()
self.assertTrue(picking.move_line_ids)
self.assertEqual(len(picking.move_line_ids), 1)
picking.move_line_ids.qty_done = 2
picking.move_line_ids.picked = True
picking._action_done()
self.assertTrue(move1.move_dest_ids)

Expand Down Expand Up @@ -248,8 +251,7 @@ def test_50_partial_chained_auto_move(self):
picking.action_confirm()
self.assertTrue(picking.move_line_ids)
self.assertEqual(len(picking.move_line_ids), 1)
picking.move_line_ids.qty_done = 1
picking.move_line_ids.reserved_uom_qty = 1
picking.move_line_ids.write({"picked": True, "quantity": 1})
picking._action_done()

# As move_dest_ids include backorders
Expand All @@ -271,7 +273,8 @@ def test_50_partial_chained_auto_move(self):
self.assertTrue(back_order)
self.assertEqual(len(back_order), 1)

back_order.move_line_ids.qty_done = 1
# back_order.move_line_ids.qty_done = 1
back_order.move_line_ids.picked = True
back_order._action_done()

self.assertEqual(len(back_order.move_ids.move_dest_ids), 2)
Expand Down Expand Up @@ -349,11 +352,9 @@ def test_60_partial_chained_auto_move(self):
move2.move_dest_ids.auto_move = False

# do partial reception of the first picking
move1.move_line_ids.qty_done = 2
move1.move_line_ids.reserved_uom_qty = 2
move1.move_line_ids.write({"picked": True, "quantity": 2})

move2.move_line_ids.qty_done = 1
move2.move_line_ids.reserved_uom_qty = 1
move2.move_line_ids.write({"picked": True, "quantity": 1})

picking._action_done()

Expand Down Expand Up @@ -452,13 +453,13 @@ def test_80_chained_auto_move_uom(self):
picking.action_confirm()
self.assertTrue(picking.move_line_ids)
self.assertEqual(len(picking.move_line_ids), 1)
picking.move_line_ids.qty_done = 2
picking.move_line_ids.picked = True
picking._action_done()
self.assertTrue(move1.move_dest_ids)

self.assertTrue(move1.move_dest_ids.auto_move)
self.assertEqual(move1.move_dest_ids.state, "done")
self.assertEqual(move1.move_dest_ids.quantity_done, 2.0)
self.assertEqual(move1.move_dest_ids.quantity, 2.0)
self.assertEqual(move1.move_dest_ids.product_qty, 24.0)

def test_90_partial_chained_auto_move_no_backorder(self):
Expand Down Expand Up @@ -525,11 +526,9 @@ def test_90_partial_chained_auto_move_no_backorder(self):
second_step_picking = move2.move_dest_ids.picking_id

# do partial reception of the first picking
move1.move_line_ids.qty_done = 2
move1.move_line_ids.reserved_uom_qty = 2
move1.move_line_ids.write({"picked": True, "quantity": 2})

move2.move_line_ids.qty_done = 1
move2.move_line_ids.reserved_uom_qty = 1
move2.move_line_ids.write({"picked": True, "quantity": 1})

res = picking.button_validate()
self.assertEqual(res.get("res_model"), "stock.backorder.confirmation")
Expand All @@ -548,8 +547,9 @@ def test_90_partial_chained_auto_move_no_backorder(self):

self.assertEqual("done", move1.move_dest_ids.state)
self.assertEqual("done", move2.move_dest_ids.state)
self.assertEqual(2.0, move1.move_dest_ids.quantity_done)
self.assertEqual(1.0, move2.move_dest_ids.quantity_done)
self.assertEqual(2.0, move1.move_dest_ids.quantity)
self.assertEqual(1.0, move2.move_dest_ids.quantity)


def test_100_partial_chained_auto_move_mixed_no_backorder(self):
"""
Expand Down Expand Up @@ -640,11 +640,9 @@ def test_100_partial_chained_auto_move_mixed_no_backorder(self):
second_step_picking = move2.move_dest_ids.picking_id

# do partial reception of the first picking
move1.move_line_ids.qty_done = 5
move1.move_line_ids.reserved_uom_qty = 5
move1.move_line_ids.write({"picked": True, "quantity": 5})

move2.move_line_ids.qty_done = 5
move2.move_line_ids.reserved_uom_qty = 5
move2.move_line_ids.write({"picked": True, "quantity": 5})

res = picking.button_validate()
self.assertEqual(res.get("res_model"), "stock.backorder.confirmation")
Expand Down Expand Up @@ -674,4 +672,4 @@ def test_100_partial_chained_auto_move_mixed_no_backorder(self):
self.assertEqual(
"partially_available", second_step_back_order.move_line_ids.state
)
self.assertEqual(5.0, second_step_back_order.move_line_ids.reserved_uom_qty)
self.assertEqual(5.0, second_step_back_order.move_line_ids.quantity)

0 comments on commit bbf0e71

Please sign in to comment.