NiO thin films deposited by Cathode magnetron sputtering were used as anode buffer layer in organic photovoltaic cells (OPVs) based on CuPc/C60 planar heterojunctions., Fjrstly, the authors show that the properties of the NiO films depend on the O2 partial pressure during peposition. The films are first conductive between 0 and 2 percent partial oxygen pressure, then they are semiconductor and p-type between 2 and 6 percent partial oxygen pressure, between 6 and 9 percent partial oxygen pressure the conduction is very low and the films are n-type and finally, for a partial oxygen pressure higher than 9 percent, the conduction is p-type. The morphology of these films depends also of the O2 partial pressure. When the NiO films is thick of 4 nm, its' peak to valley roughness is 6 nm, when it is sputtered with a gas containing 7.4 percent of oxygen, while it is more than double, 13.5 nm, when the partial pressure of oxygen is 16.67 percent. This roughness implies that a forming process, i.e. a decrease of the leakage current, is necessary for the OPVs. The forming process is not necessary if the NiO ABL is thick of 20 nm.