[12.0][IMP] Improved _compute_qty code

This commit is contained in:
Murtuza Saleh
2020-09-03 15:12:54 +05:30
committed by Kitti U
parent 1536f73a58
commit e5f3817f08

View File

@@ -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)