-
state
-
location_id
-
order_id
-
order_id.picking_type_id
-
order_id.picking_type_id.default_location_dest_id
-
to_refund
-
product_uom
-
quantity
-
origin_returned_move_id
-
product_qty
-
qty_in_receipt
-
qty_received
|
for line in self:
precision_digits = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)
total = 0.0
for move in line.move_ids:
if move.state not in ["cancel", "done"]:
if (
move.location_id
== self.order_id.picking_type_id.default_location_dest_id
):
# This is a return to vendor
if move.to_refund:
total -= move.product_uom._compute_quantity(
move.quantity, line.product_uom
)
elif (
move.origin_returned_move_id
and move.origin_returned_move_id._is_dropshipped()
and not move._is_dropshipped_returned()
):
# Edge case: the dropship is returned to the stock,
# no to the supplier.
# In this case, the received quantity on the PO is
# set although we didn't receive the product
# physically in our stock. To avoid counting the
# quantity twice, we do nothing.
pass
else:
total += move.product_uom._compute_quantity(
move.quantity, line.product_uom
)
line.qty_in_receipt = total
if (
float_compare(
line.product_qty,
line.qty_in_receipt + line.qty_received,
precision_digits=precision_digits,
)
== 1
):
line.pending_to_receive = True
else:
line.pending_to_receive = False
|
|