+ def onchange_move_type(self, cr, uid, ids, type, context=None):
+ """ On change of move type gives sorce and destination location.
+ @param type: Move Type
+ @return: Dictionary of values
+ """
+ mod_obj = self.pool.get('ir.model.data')
+ location_source_id = False
+ location_dest_id = False
+ if type == 'in':
+ location_source_id = 'stock_location_suppliers'
+ location_dest_id = 'stock_location_stock'
+ elif type == 'out':
+ location_source_id = 'stock_location_stock'
+ location_dest_id = 'stock_location_customers'
+ if location_source_id:
+ try:
+ location_model, location_source_id = mod_obj.get_object_reference(cr, uid, 'stock', location_source_id)
+ except ValueError, e:
+ location_source_id = False
+ if location_dest_id:
+ try:
+ location_model, location_dest_id = mod_obj.get_object_reference(cr, uid, 'stock', location_dest_id)
+ except ValueError, e:
+ location_dest_id = False
+ return {'value':{'location_id': location_source_id, 'location_dest_id': location_dest_id}}
+