Skip to content

Commit d447fb1

Browse files
committed
[FIX] stock_move_line_devaluation: fix return wizard quantity in tests
1 parent 6b63c21 commit d447fb1

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

stock_move_line_devaluation/tests/test_stock_move_line_devaluation.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def setUpClass(cls):
88
super().setUpClass()
99

1010
cls.partner = cls.env["res.partner"].create(
11-
{"name": "Test Devaluation Customer", "customer_rank": 1}
11+
{"name": "Test Devaluation Customer"}
1212
)
1313
cls.pricelist = cls.env["product.pricelist"].create(
1414
{"name": "Test Devaluation Pricelist"}
@@ -26,7 +26,6 @@ def setUpClass(cls):
2626
cls.stock_location = cls.env.ref("stock.stock_location_stock")
2727
cls.customer_location = cls.env.ref("stock.stock_location_customers")
2828
cls.picking_type_out = cls.env.ref("stock.picking_type_out")
29-
cls.picking_type_in = cls.env.ref("stock.picking_type_in")
3029
cls.uom_unit = cls.env.ref("uom.product_uom_unit")
3130

3231
# Ensure stock availability
@@ -68,18 +67,21 @@ def _create_outgoing_picking(self, qty=5.0):
6867

6968
def _create_return(self, picking, qty):
7069
"""Create a return for a picking using the stock return wizard."""
70+
wizard_ctx = {
71+
"active_id": picking.id,
72+
"active_ids": picking.ids,
73+
"active_model": "stock.picking",
74+
}
7175
return_wizard = (
72-
self.env["stock.return.picking"]
73-
.with_context(active_id=picking.id, active_model="stock.picking")
74-
.create({})
76+
self.env["stock.return.picking"].with_context(**wizard_ctx).create({})
7577
)
7678
for line in return_wizard.product_return_moves:
77-
if line.product_id == self.product:
78-
line.quantity = qty
79+
line.write({"quantity": qty})
7980
result = return_wizard.create_returns()
8081
return_picking = self.env["stock.picking"].browse(result["res_id"])
82+
return_picking.action_assign()
8183
for ml in return_picking.move_line_ids:
82-
ml.qty_done = qty
84+
ml.qty_done = ml.reserved_uom_qty or qty
8385
return_picking._action_done()
8486
return return_picking
8587

0 commit comments

Comments
 (0)