[FIX] stock: only apply transformations to form fields of stock.change.product.qty...
authorXavier Morel <xmo@openerp.com>
Thu, 22 Dec 2011 13:46:20 +0000 (14:46 +0100)
committerXavier Morel <xmo@openerp.com>
Thu, 22 Dec 2011 13:46:20 +0000 (14:46 +0100)
Also remove useless & bonkers conditionals (checking that a key exists
in a dict and then setting one of its sub-keys whether or not the test
succeeded is going to blow up either way), and simplify the code since

    if condition:
        some_value = True
    else:
        some_value = False

can just be written as:

    some_value = condition

lp bug: https://launchpad.net/bugs/905188 fixed

bzr revid: xmo@openerp.com-20111222134620-bpi9d24msbia4ymm

addons/stock/wizard/stock_change_product_qty.py

index a2b4b6e..9d3de56 100644 (file)
@@ -35,17 +35,14 @@ class stock_change_product_qty(osv.osv_memory):
     }
 
     def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
-        result = super(stock_change_product_qty, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
+        fvg = super(stock_change_product_qty, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
         product_id = context and context.get('active_id', False) or False
 
-        if (context.get('active_model') == 'product.product') and product_id:
+        if view_type == 'form' and (context.get('active_model') == 'product.product') and product_id:
             prod_obj = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
-            fields = result.get('fields', {})
-            if fields and (prod_obj.track_production == True) and (fields.get('prodlot_id')):
-                result['fields']['prodlot_id']['required'] =  True
-            else:
-                result['fields']['prodlot_id']['required'] = False
-        return result
+            fvg['fields']['prodlot_id']['required'] =  prod_obj.track_production
+
+        return fvg
 
     def default_get(self, cr, uid, fields, context):
         """ To get default values for the object.