From 4da82776ffb2a14c4d291946eadf5bd335595a0a Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 28 Mar 2019 10:10:43 +0000 Subject: [PATCH] [FIX] purchase_stock: return dropship - Set an internal location as a return location - Create a SO with a dropship product, validate and deliver - Return the product, and choose the internal location as the return location. The received quantity on the PO is counted twice. Since the return is an 'in' move linked to a PO, it is automatically counted as incoming quantity. This case is quite specific, so we explicitly add an exception in case the origin move was a dropship, but the return is not a returned dropship. opw-1958228 closes odoo/odoo#32205 Signed-off-by: Nicolas Martinelli (nim) --- addons/purchase_stock/models/purchase.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index b14a2d8073c..b1f861c041c 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -361,6 +361,12 @@ class PurchaseOrderLine(models.Model): if move.location_dest_id.usage == "supplier": if move.to_refund: total -= move.product_uom._compute_quantity(move.product_uom_qty, line.product_uom) + elif 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.product_uom_qty, line.product_uom) line.qty_received = total