From d0a0b7d91de08612cb03bdead4d2789185884402 Mon Sep 17 00:00:00 2001
From: Guewen Baconnier <guewen@gmail.com>
Date: Wed, 9 Jul 2014 13:56:24 +0200
Subject: [PATCH] [FIX] purchase: skip move if not linked to a purchase order

When this situation happens. the 'cost' is None and the web interface cannot handle this value, provoking a JS error. Thus, prefer to fallback on the standard way to get the cost: based on the current standard price of the product.
Fixes #1032
---
 addons/purchase/stock.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py
index d0055d80c7f2..24df0b5eaa08 100644
--- a/addons/purchase/stock.py
+++ b/addons/purchase/stock.py
@@ -127,7 +127,7 @@ class stock_partial_picking(osv.osv_memory):
     # Overridden to inject the purchase price as true 'cost price' when processing
     # incoming pickings.
     def _product_cost_for_average_update(self, cr, uid, move):
-        if move.picking_id.purchase_id:
+        if move.picking_id.purchase_id and move.purchase_line_id:
             return {'cost': move.purchase_line_id.price_unit,
                     'currency': move.picking_id.purchase_id.pricelist_id.currency_id.id}
         return super(stock_partial_picking, self)._product_cost_for_average_update(cr, uid, move)
-- 
GitLab