mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[12.0][IMP] Improved _compute_qty code
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user