}
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.