Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion purchase_request/models/stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _prepare_purchase_request_line(self, request_id, procurement):
"product_qty": procurement_uom_po_qty,
"request_id": request_id.id,
"move_dest_ids": [
(4, x.id) for x in procurement.values.get("move_dest_ids", [])
(4, x.id) for x in (procurement.values.get("move_dest_ids") or [])
],
Comment thread
fsmw marked this conversation as resolved.
"orderpoint_id": procurement.values.get("orderpoint_id", False)
and procurement.values.get("orderpoint_id").id,
Expand Down
27 changes: 27 additions & 0 deletions purchase_request/tests/test_purchase_request_procurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,30 @@ def test_origin(self):
move4 = self._procurement_group_run("Split", self.product_1, 10)
self.assertEqual(move4.created_purchase_request_line_id.request_id, pr)
self.assertEqual(pr.origin, "Test Origin, Test, Split")

def test_procurement_without_move_dest_ids(self):
"""Test that procurement works when move_dest_ids is False/None.

This tests the fix for issue #2927 where move_dest_ids could be
a boolean False in Odoo 18 instead of an empty list, causing
TypeError: 'bool' object is not iterable
"""
move = self.env["stock.move"].create(
{
"reservation_date": fields.Datetime.now(),
"location_dest_id": self.customer_location.id,
"location_id": self.location.id,
"name": self.product_1.name,
"origin": "Test Move Dest Ids",
"procure_method": "make_to_order",
"product_id": self.product_1.id,
"product_uom": self.product_1.uom_id.id,
"product_uom_qty": 5,
"route_ids": [(4, self.route_buy.id)],
# Explicitly set move_dest_ids to False (simulating Odoo 18 edge case)
"move_dest_ids": [(5, 0, 0)],
}
)
# This should not raise TypeError: 'bool' object is not iterable
move._action_confirm()
self.assertTrue(move.created_purchase_request_line_id)
Loading