[FIX] stock: moves link on product form opening wrong view
authorRaphaël Valyi <rvalyi@gmail.com>
Tue, 26 Aug 2014 22:07:24 +0000 (19:07 -0300)
committerMartin Trigaux <mat@openerp.com>
Wed, 27 Aug 2014 12:39:13 +0000 (14:39 +0200)
Fixes #2008

addons/stock/product.py

index 7289e8d..bb60b77 100644 (file)
@@ -433,10 +433,13 @@ class product_template(osv.osv):
         products = self._get_products(cr, uid, ids, context=context)
         result = self._get_act_window_dict(cr, uid, 'stock.act_product_stock_move_open', context=context)
         if len(ids) == 1 and len(products) == 1:
-            result['context'] = "{'default_product_id': " + str(products[0]) + ", 'search_default_product_id': " + str(products[0]) + "}"
+            ctx = "{'tree_view_ref':'stock.view_move_tree', \
+                  'default_product_id': %s, 'search_default_product_id': %s}" \
+                  % (products[0], products[0])
+            result['context'] = ctx
         else:
             result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]"
-            result['context'] = "{}"
+            result['context'] = "{'tree_view_ref':'stock.view_move_tree'}"
         return result