Skip to content

Commit

Permalink
[18.0][MIG] stock_orderpoint_move_link: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HviorForgeFlow committed Jan 15, 2025
1 parent c74c810 commit e71b020
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion stock_orderpoint_move_link/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Stock Orderpoint Move Link",
"summary": "Link Reordering rules to stock moves",
"version": "16.0.1.0.1",
"version": "18.0.1.0.1",
"license": "LGPL-3",
"website": "https://github.com/OCA/stock-logistics-orderpoint",
"author": "ForgeFlow, Odoo Community Association (OCA)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,5 @@ def action_view_stock_picking(self):
"stock.action_picking_tree_all"
)
result["context"] = {}
picking_ids = (
self.env["stock.move"]
.search([("orderpoint_ids", "in", self.id)])
.mapped("picking_id")
)
result["domain"] = "[('id','in',%s)]" % picking_ids.ids
result["domain"] = f"[('move_ids.orderpoint_ids', 'in', {self.ids})]"
return result
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_01_stock_orderpoint_move_link(self):
move = self.move_obj.search(
[("orderpoint_ids", "=", self.orderpoint_need_loc.id)]
)
self.assertTrue(len(move), 2)
self.assertEqual(len(move), 2)

def test_02_stock_orderpoint_move_link_action_view(self):
sp_orderpoint = self.move_obj.search(
Expand All @@ -114,3 +114,24 @@ def test_02_stock_orderpoint_move_link_action_view(self):
result = self.orderpoint_need_loc.action_view_stock_picking()
sp_action = self.picking_obj.search(ast.literal_eval(result["domain"]))
self.assertEqual(sp_orderpoint, sp_action)

def test_03_stock_orderpoint_move_link_merge_moves(self):
# Previous moves generation
moves = self.move_obj.search(
[("orderpoint_ids", "=", self.orderpoint_need_loc.id)]
)
self.assertEqual(moves.mapped("product_qty"), [50.0, 50.0])
self.assertEqual(len(moves), 2)
self.assertEqual(moves.mapped("orderpoint_ids"), self.orderpoint_need_loc)
# Force reordering (new moves will be merged in the old ones)
self.orderpoint_need_loc.write(
{
"product_min_qty": 60.0,
"product_max_qty": 75.0,
}
)
self.group_obj.run_scheduler()
# Check merged moves
self.assertEqual(moves.mapped("product_qty"), [75.0, 75.0])
self.assertEqual(len(moves), 2)
self.assertEqual(moves.mapped("orderpoint_ids"), self.orderpoint_need_loc)

0 comments on commit e71b020

Please sign in to comment.