The company will open a factory in Shanghai to produce “mega pack” batteries that will be able to supply power to local grids where demand is high.