[FIX] stock: only apply transformations to form fields of stock.change.product.qty when fields_view_get is on a form view

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
This commit is contained in:
Xavier Morel 2011-12-22 14:46:20 +01:00
parent fe56720ee9
commit 48c8f9a47a
1 changed files with 5 additions and 8 deletions

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