From ab0babf3e93f0ed5283b6d458b1087d24049c8fd Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 4 Apr 2019 13:43:20 +0200 Subject: [PATCH] [FIX] purchase_stock: move code at the right place Oversight of previous forward-port. --- addons/purchase_stock/models/purchase.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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.