From 506c52bcd1fe0acf14cd36ac7ddc2a18505c1308 Mon Sep 17 00:00:00 2001
From: Josse Colpaert <jco@odoo.com>
Date: Tue, 18 Nov 2014 11:38:58 +0100
Subject: [PATCH] [FIX] Avoid access error on XML id in browse when choosing
 picking type for manual purchase order.  As they are ordered by sequence,
 just take the first you can find.

---
 addons/purchase/purchase.py | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index f08c16943b6d..60fbac8a8619 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -153,11 +153,6 @@ class purchase_order(osv.osv):
         type_obj = self.pool.get('stock.picking.type')
         user_obj = self.pool.get('res.users')
         company_id = user_obj.browse(cr, uid, uid, context=context).company_id.id
-        pick_type = obj_data.get_object_reference(cr, uid, 'stock', 'picking_type_in') and obj_data.get_object_reference(cr, uid, 'stock', 'picking_type_in')[1] or False
-        if pick_type:
-            type = type_obj.browse(cr, uid, pick_type, context=context)
-            if type and type.warehouse_id and type.warehouse_id.company_id.id == company_id:
-                return pick_type
         types = type_obj.search(cr, uid, [('code', '=', 'incoming'), ('warehouse_id.company_id', '=', company_id)], context=context)
         if not types:
             types = type_obj.search(cr, uid, [('code', '=', 'incoming'), ('warehouse_id', '=', False)], context=context)
-- 
GitLab