diff --git a/stock_request/models/stock_request.py b/stock_request/models/stock_request.py index f1c545398..099a0b3c6 100644 --- a/stock_request/models/stock_request.py +++ b/stock_request/models/stock_request.py @@ -171,7 +171,14 @@ class StockRequest(models.Model): ) def _compute_qty(self): for request in self: - done_qty = sum(request.allocation_ids.mapped("allocated_product_qty")) + incoming_qty = 0.0 + other_qty = 0.0 + for allocation in request.allocation_ids: + if allocation.stock_move_id.picking_code == "incoming": + incoming_qty += allocation.allocated_product_qty + else: + other_qty += allocation.allocated_product_qty + done_qty = abs(other_qty - incoming_qty) open_qty = sum(request.allocation_ids.mapped("open_product_qty")) uom = request.product_id.uom_id request.qty_done = uom._compute_quantity(done_qty, request.product_uom_id)