To Create a transit location with company_id being the given company_id. This is needed in case of resupply routes between warehouses belonging to the same company, because we don't want to create accounting entries at that time. For this use this code given below in .py file.
def create_transitlocation(self, cr, uid, company_id, company_name, context=None):
data_obj = self.pool.get('ir.model.data')
try:
parent_loc = data_obj.get_object_reference(cr, uid, 'stock', 'stock_location_locations')[1]
except:
parent_loc = False
location_vals = {
'name': _('%s: Transit Location') % company_name,
'usage': 'transit',
'company_id': company_id,
'location_id': parent_loc,
}
location_id = self.pool.get('stock.location').create(cr, uid, location_vals, context=context)
self.write(cr, uid, [company_id], {'internal_transit_location_id': location_id}, context=context)
0 Comment(s)