Skip to content

Commit

Permalink
[FIX] purchase_stock: return subcontracted product
Browse files Browse the repository at this point in the history
- Create a product P with a subcontracted BOM
- Create a PO for P, 10 units
- Receive 10 units
- Return 3 units and specify 'To Refund'

13 units are considered received.

The reason is that we don't return to a vendor location, but an internal
location.

We subtract the quantity when the following conditions are met:
- we ask for a refund
- we return to an internal location
- the return location is not in the warehouse of the move

The solution is similar to odoo/enterprise#9647

opw-2235157

closes odoo#50119

X-original-commit: 5fd6c5b
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information
nim-odoo committed Apr 24, 2020
1 parent 62fbf6e commit e6a1e24
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions addons/purchase_stock/models/purchase.py
Expand Up @@ -291,6 +291,15 @@ def _compute_qty_received(self):
# receive the product physically in our stock. To avoid counting the
# quantity twice, we do nothing.
pass
elif (
move.location_dest_id.usage == "internal"
and move.to_refund
and move.location_dest_id
not in self.env["stock.location"].search(
[("id", "child_of", move.warehouse_id.view_location_id.id)]
)
):
total -= move.product_uom._compute_quantity(move.product_uom_qty, line.product_uom)
else:
total += move.product_uom._compute_quantity(move.product_uom_qty, line.product_uom)
line.qty_received = total
Expand Down

0 comments on commit e6a1e24

Please sign in to comment.