Skip to content
Snippets Groups Projects
Commit f75f5b53 authored by Walid HANNICHE (waha)'s avatar Walid HANNICHE (waha)
Browse files

[FIX] stock: set correct return quantity

Steps to reproduce:
-Enable multistep routes for manufacturing
-create a MO for 50 products
-In internal transfers from Stock to Pre-production validate
part of the tansfer (20 units) and create a back order
for the remaining qty (30 units)
-create and validate another pertail transfer (3 units)with a back order
for the remaining quantity (27 units)
-create a return for the last validated transfers

Bug:
the default qty for the return is set to -20 where it should be 3
this commit[1] deducts the previous transfers from the returned amount

Fix:
only deduct returns from current transfer

opw-3104699
[1]:https://github.com/odoo/odoo/commit/7b08f0ae0a39e8f575b21e744de16264b6365704



closes odoo/odoo#115110

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 7dbdce3c
No related branches found
No related tags found
No related merge requests found
......@@ -1082,6 +1082,36 @@ class TestSaleStock(TestSaleCommon, ValuationReconciliationTestCommon):
self.assertEqual(so.order_line[1].qty_delivered, 1)
self.assertEqual(so.order_line[1].product_uom.id, uom_km_id)
def test_multiple_returns(self):
# Creates a sale order for 10 products.
sale_order = self._get_new_sale_order()
# Valids the sale order, then valids the delivery.
sale_order.action_confirm()
picking = sale_order.picking_ids
picking.move_lines.write({'quantity_done': 10})
picking.button_validate()
# Creates a return from the delivery picking.
return_picking_form = Form(self.env['stock.return.picking']
.with_context(active_ids=picking.ids, active_id=picking.id,
active_model='stock.picking'))
return_wizard = return_picking_form.save()
# Check that the correct quantity is set on the retrun
self.assertEqual(return_wizard.product_return_moves.quantity, 10)
return_wizard.product_return_moves.quantity = 2
# Valids the return picking.
res = return_wizard.create_returns()
return_picking = self.env['stock.picking'].browse(res['res_id'])
return_picking.move_lines.write({'quantity_done': 2})
return_picking.button_validate()
# Creates a second return from the delivery picking.
return_picking_form = Form(self.env['stock.return.picking']
.with_context(active_ids=picking.ids, active_id=picking.id,
active_model='stock.picking'))
return_wizard = return_picking_form.save()
# Check that the remaining quantity is set on the retrun
self.assertEqual(return_wizard.product_return_moves.quantity, 8)
class TestSaleStockOnly(SavepointCase):
......
......@@ -79,7 +79,7 @@ class ReturnPicking(models.TransientModel):
def _prepare_stock_return_picking_line_vals_from_move(self, stock_move):
quantity = stock_move.product_qty
for move in stock_move.move_dest_ids:
if move.origin_returned_move_id and move.origin_returned_move_id != stock_move:
if not move.origin_returned_move_id or move.origin_returned_move_id != stock_move:
continue
if move.state in ('partially_available', 'assigned'):
quantity -= sum(move.move_line_ids.mapped('product_qty'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment