[FIX] purchase_stock: return subcontracted product
- 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/odoo#50119 X-original-commit: 5fd6c5b65e00dcac77b232b9f47b2292d86c6b0f Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -291,6 +291,15 @@ class PurchaseOrderLine(models.Model):
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user