Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion purchase_stock_ux/models/purchase_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,28 @@ def _onchange_product_qty(self):
return {"warning": warning_mess}
return {}

@api.depends("qty_received_method", "qty_received_manual")
def _compute_qty_received(self):
super()._compute_qty_received()
for line in self.filtered(lambda l: l.qty_received_method in ["manual", "stock_moves"]):
exchange_move_ids = line.move_ids.filtered(
lambda m: m.state == "done" and m.location_id.usage != "supplier" and m._is_exchange_move_helper()
)
if exchange_move_ids:
line.qty_received -= sum(
line.product_uom._compute_quantity(move.product_uom_qty, line.product_uom)
for move in exchange_move_ids
)

@api.depends("order_id.state", "move_ids.state")
def _compute_qty_returned(self):
for line in self:
qty = 0.0
for move in line.move_ids.filtered(
lambda m: m.state == "done" and m.location_id.usage != "supplier" and m.to_refund
lambda m: m.state == "done"
and m.location_id.usage != "supplier"
and m.to_refund
and not m.is_exchange_move
):
qty += move.product_uom._compute_quantity(move.product_uom_qty, line.product_uom)
line.qty_returned = qty
Expand Down