[FIX] purchase: return dropship

Backport of 4da82776ff.
Because of e38ed7c7 the code moved between versions, but is otherwise identical.

- 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

opw 2045685

closes odoo/odoo#35831

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-08-20 08:46:36 +00:00
committed by Nans Lefebvre
parent 5e3d49bc47
commit 7cbc088d84
+6
View File
@@ -592,6 +592,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