|
|
for request in self:
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,
rounding_method="HALF-UP",
)
request.qty_in_progress = uom._compute_quantity(
open_qty,
request.product_uom_id,
rounding_method="HALF-UP",
)
request.qty_cancelled = (
max(
0,
uom._compute_quantity(
request.product_qty - done_qty - open_qty,
request.product_uom_id,
rounding_method="HALF-UP",
),
)
if request.allocation_ids
else 0
)
|
|