[IMP] Only show number of variants when more than one + bug cursor Compute Minimum...
authorJosse Colpaert <jco@odoo.com>
Wed, 16 Jul 2014 11:50:56 +0000 (13:50 +0200)
committerJosse Colpaert <jco@odoo.com>
Wed, 16 Jul 2014 11:50:56 +0000 (13:50 +0200)
addons/product/product_view.xml
addons/stock/wizard/orderpoint_procurement.py

index 106cc04..007f2c0 100644 (file)
                                              <field name="name"/> 
                                         </a>
                                     </h4>
-                                    <a name="%(product.product_variant_action)d" type="action">
+                                    <a name="%(product.product_variant_action)d" type="action" t-if="record.product_variant_count.raw_value&gt;1" >
                                         <t t-esc="record.product_variant_count.value"/> Variants
                                     </a>
                                     <div name="tags"/>
index f898dac..4a591bc 100644 (file)
 
 import threading
 from openerp.osv import fields,osv
+from openerp.api import Environment
 
 class procurement_compute(osv.osv_memory):
     _name = 'procurement.orderpoint.compute'
-    _description = 'Automatic Order Point'
+    _description = 'Compute Minimum Stock Rules'
 
 
     def _procure_calculation_orderpoint(self, cr, uid, ids, context=None):
@@ -40,16 +41,16 @@ class procurement_compute(osv.osv_memory):
         @param ids: List of IDs selected
         @param context: A standard dictionary
         """
-        proc_obj = self.pool.get('procurement.order')
-        #As this function is in a new thread, I need to open a new cursor, because the old one may be closed
-        new_cr = self.pool.cursor()
-        user_obj = self.pool.get('res.users')
-        user = user_obj.browse(new_cr, uid, uid, context=context)
-        for comp in user.company_ids:
-            proc_obj._procure_orderpoint_confirm(new_cr, uid, use_new_cursor=new_cr.dbname, company_id = comp.id, context=context)
-        #close the new cursor
-        new_cr.close()
-        return {}
+        with Environment.manage():
+            proc_obj = self.pool.get('procurement.order')
+            #As this function is in a new thread, I need to open a new cursor, because the old one may be closed
+            new_cr = self.pool.cursor()
+            user_obj = self.pool.get('res.users')
+            company_id = user_obj.browse(new_cr, uid, uid, context=context).company_id.id
+            proc_obj._procure_orderpoint_confirm(new_cr, uid, use_new_cursor=new_cr.dbname, company_id = company_id, context=context)
+            #close the new cursor
+            new_cr.close()
+            return {}
 
     def procure_calculation(self, cr, uid, ids, context=None):
         """
@@ -59,6 +60,7 @@ class procurement_compute(osv.osv_memory):
         @param ids: List of IDs selected
         @param context: A standard dictionary
         """
+        
         threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context))
         threaded_calculation.start()
         return {'type': 'ir.actions.act_window_close'}