diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index fbfd4120baa..3fffa3b490d 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -246,6 +246,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 @@ -378,12 +384,6 @@ class PurchaseOrderLine(models.Model): values.append(val) return self.env['stock.move'].create(values) - 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 def _merge_in_existing_line(self, product_id, product_qty, product_uom, location_id, name, origin, values): """ This function purpose is to be override with the purpose to forbide _run_buy method to merge a new po line in an existing one.