[IMP] stock,mrp: Used default_get instead of defaults and clean the code
bzr revid: sbh@tinyerp.com-20100319072012-olyachwz80s9d3pv
This commit is contained in:
parent
33565b9226
commit
07c8efd1f4
|
@ -47,13 +47,11 @@ class change_production_qty(osv.osv_memory):
|
|||
@return: A dictionary which of fields with values.
|
||||
|
||||
"""
|
||||
res = {}
|
||||
record_id = context and context.get('active_id',False)
|
||||
if not record_id:
|
||||
return res
|
||||
res = super(change_production_qty, self).default_get(cr, uid, fields, context=context)
|
||||
prod_obj = self.pool.get('mrp.production')
|
||||
prod = prod_obj.browse(cr, uid, record_id)
|
||||
res['product_qty'] = prod.product_qty
|
||||
prod = prod_obj.browse(cr, uid, context.get('active_id'))
|
||||
if 'product_qty' in fields:
|
||||
res.update({'product_qty': prod.product_qty})
|
||||
return res
|
||||
|
||||
def change_prod_qty(self, cr, uid, ids, context):
|
||||
|
|
|
@ -30,8 +30,8 @@ class pos_details(osv.osv_memory):
|
|||
_description = 'Sales Details'
|
||||
|
||||
_columns = {
|
||||
'date_start': fields.date('Date Start'),
|
||||
'date_end': fields.date('Date End'),
|
||||
'date_start': fields.date('Date Start',required=True),
|
||||
'date_end': fields.date('Date End',required=True)
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context={}):
|
||||
|
|
|
@ -42,10 +42,11 @@ class change_standard_price(osv.osv_memory):
|
|||
@return: A dictionary which of fields with values.
|
||||
|
||||
"""
|
||||
rec_id = context and context.get('active_id', False)
|
||||
res = {}
|
||||
price = self.pool.get('product.product').browse(cr, uid, rec_id)
|
||||
res['new_price'] = price.standard_price
|
||||
|
||||
res = super(change_standard_price, self).default_get(cr, uid, fields, context=context)
|
||||
price = self.pool.get('product.product').browse(cr, uid, context.get('active_id', False))
|
||||
if 'new_price' in fields:
|
||||
res.update({'new_price':price.standard_price})
|
||||
return res
|
||||
|
||||
def change_price(self, cr, uid, ids, context):
|
||||
|
|
|
@ -47,18 +47,13 @@ class stock_inventory_line_split(osv.osv_memory):
|
|||
@return: A dictionary which of fields with values.
|
||||
|
||||
"""
|
||||
res = {}
|
||||
record_id = context and context.get('active_id',False)
|
||||
res = super(stock_inventory_line_split, self).default_get(cr, uid, fields, context=context)
|
||||
if not record_id:
|
||||
return res
|
||||
|
||||
lot= self.pool.get('stock.inventory.line').browse(cr, uid, record_id)
|
||||
res['product_id']=line.product_id.id
|
||||
line= self.pool.get('stock.inventory.line').browse(cr, uid, record_id)
|
||||
if 'product_id' in fields:
|
||||
res.update({'product_id':line.product_id.id})
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def split(self, cr, uid, ids, line_ids, context=None):
|
||||
"""
|
||||
To split stock inventory lines according to production lot
|
||||
|
|
|
@ -79,15 +79,18 @@ class stock_move_consume(osv.osv_memory):
|
|||
@return: default values of fields_list
|
||||
|
||||
"""
|
||||
res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context)
|
||||
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
|
||||
val = {
|
||||
'product_id': move.product_id.id,
|
||||
'product_uom': move.product_uom.id,
|
||||
'product_qty': move.product_qty,
|
||||
'location_id': move.location_id.id,
|
||||
}
|
||||
return val
|
||||
|
||||
if 'product_id' in fields:
|
||||
res.update({'product_id': move.product_id.id})
|
||||
if 'product_uom' in fields:
|
||||
res.update({'product_uom': move.product_uom.id})
|
||||
if 'product_qty' in fields:
|
||||
res.update({'product_qty': move.product_qty.id})
|
||||
if 'location_id' in fields:
|
||||
res.update({'location_id': move.location_id.id})
|
||||
return res
|
||||
|
||||
def do_move_consume(self, cr, uid, ids, context={}):
|
||||
"""
|
||||
To move consumed products
|
||||
|
@ -149,19 +152,30 @@ class split_in_production_lot(osv.osv_memory):
|
|||
_name = "stock.move.split"
|
||||
_description = "Split in Production lots"
|
||||
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
"""
|
||||
Get default values
|
||||
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields_list: List of fields for default value
|
||||
@param context: A standard dictionary
|
||||
|
||||
@return: default values of fields_list
|
||||
|
||||
"""
|
||||
|
||||
res = super(split_in_production_lot, self).default_get(cr, uid, fields, context=context)
|
||||
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
|
||||
if 'product_id' in fields:
|
||||
res.update({'product_id': move.product_id.id})
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
|
||||
'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Lots Number')
|
||||
}
|
||||
|
||||
def _get_product_id(self, cr, uid, context):
|
||||
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
|
||||
return move.product_id.id
|
||||
|
||||
_defaults = {
|
||||
'product_id': _get_product_id,
|
||||
}
|
||||
|
||||
def split_lot(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
To split a lot
|
||||
|
@ -242,8 +256,6 @@ class split_in_production_lot(osv.osv_memory):
|
|||
update_val['product_qty'] = quantity_rest
|
||||
update_val['product_uos_qty'] = uos_qty_rest
|
||||
move_obj.write(cr, uid, [move.id], update_val)
|
||||
|
||||
|
||||
return new_move
|
||||
split_in_production_lot()
|
||||
|
||||
|
|
Loading…
Reference in New Issue