When we lift an object with constant velocity the work done by us is $mgh$, and that by gravity is $-mgh$. The potential energy gained will come from the work done ( $PE =mgh$ ). But how can the object gain potential energy if the net work done is zero? If work by us is converted into potential energy then what is the effect of work done by gravity, where does it go?
Consider the object as the system.
To keep the object moving at constant velocity there are two equal and opposite external forces acting on it.
The force that you exert on it and the force of gravitation attraction on it.
You apply a force on the object and do work $mgh$ on the object and the gravitational force does the work $-mgh$ on the object.
Your work is positive because the force you apply and the displacement are both in the same direction.
The work done by the gravitational attraction is negative becuse the direction of the gravitational force is in the opposite direction to the displacement.
So the net work done on the object is zero and that means that the kinetic energy of the object does not change.
It is inappropriate to talk about potential energy in regard to the chosen system which is the object.
It is the object and Earth system which has the potential energy not the object alone. When you do $mgh$ amount of work on the Earth and object you raise the potential energy of the system by $mgh$.
You might ask what about the gravitational attraction on the object (force on object due to Earth)?
Well that force is an internal force for the Earth and object system and has a N3L pair which is the attractive force on the Earth due to the object.
The change in PE is not given by the net work but just by the work done by the gravitational field (with negative sign). This is a definition. You are probable confusing the change in PE with the change in KE which is indeed given by the net work (work-energy theorem).
In you case, the net wok is zero so there is no change in KE (constant speed). The work done by gravity is -mgh and the change in PE is mgh (PE increases).
When we lift an object with constant velocity the work done by us is mgh
Yes, when you lift a brick you do work on it. You add energy to it. You increase its mass. Its mass-energy is increased, and we call the extra energy gravitational potential energy. It's important to note that it isn't in "the system", it's in the brick.
You can work this out if you imagine throwing a brick upwards. Momentum is equal and opposite, such that p1=m1v1 = p2=m2v2 where m1 is the mass of the Earth and m2 is the mass of the brick. However KE=½mv² so KE1 ≠ KE2. The Earth doesn't move in any noticeable way, so the brick gets just about all of the kinetic energy. As the brick slows down this is converted into potential energy. But again, it's in the brick. If you throw your brick upwards at 11.7 km/s, the brick along with all the energy you gave it leaves the system forever. Because 11.7 km/s is escape velocity.
and that by gravity is -mgh.
Gravity doesn't actually do any work on a body. We call it a force, but it isn't a force in the Newtonian sense. Imagine you threw the brick upwards at 10m/s giving it some kinetic energy. Gravity converts the kinetic energy into potential energy, which is mass-energy, such that at the highest point the brick is momentarily motionless, and its mass-energy is at a maximum. Then as it falls gravity converts some of this mass-energy into kinetic energy. When the brick hits the ground this kinetic energy is dissipated, and the brick is left with a mass deficit. See the Wikipedia binding energy article. When you separate two bodies you increase their mass. When one's smaller than the other, you increase the mass of the smaller body more.
The potential energy gained will come from the work done (PE=mgh).
That's right. When you lift the brick you do work on it and you increase its mass.
But how can the object gain potential energy if the net work done is zero?
It isn't zero.
If work by us is converted into potential energy then what is the effect of work done by gravity, where does it go?
The work done by us in lifting the brick goes into the brick. When it falls down gravity doesn't do any work, it just converts mass-energy aka potential energy into kinetic energy. When this is dissipated you're left with a mass deficit.