A method, for being performed by a control device, for controlling oil supply to an electrical machine of a vehicle powertrain comprising an oil system configured to supply oil to a transmission and an electrical machine of a vehicle powertrain, the oil system comprising: a mechanical pump configured to transfer oil to a first supply conduit of the oil system, a speed of the mechanical pump being dependent on rotational speed of the electric machine; a second supply conduit configured to supply oil to the transmission, the second supply conduit fluidly connected to the first supply conduit at a downstream end of the first supply conduit; and a third supply conduit configured to supply oil to the electrical machine, the third supply conduit fluidly connected to the first supply conduit at the downstream end of the first supply conduit, wherein the oil system (10( further comprises a controllable valve configured to control an amount of oil supplied to the electrical machine via the third supply conduit through control of oil pressure distribution between the second supply conduit and the third supply conduit, the method comprising a step of: in response to a determination that a predetermined criterion is fulfilled, controlling the controllable valve to an at least partially throttled position, unless the controllable valve is already in said position; wherein the predetermined criterion is that: - the oil temperature at the downstream end of the first supply conduit is above a predetermined temperature threshold, - the electrical machine is operated above an upper power threshold, and - the rotational speed of the electrical machine is within a predetermined rotational speed interval, said predetermined rotational speed interval being defined by a lower rotational speed threshold and an upper rotational speed threshold. a second supply conduit configured to supply oil to the transmission, the second supply conduit fluidly connected to the first supply conduit at a downstream end of the first supply conduit; and a third supply conduit configured to supply oil to the electrical machine, the third supply conduit fluidly connected to the first supply conduit at the downstream end of the first supply conduit, wherein the oil system (10( further comprises a controllable valve configured to control an amount of oil supplied to the electrical machine via the third supply conduit through control of oil pressure distribution between the second supply conduit and the third supply conduit, the method comprising a step of: in response to a determination that a predetermined criterion is fulfilled, controlling the controllable valve to an at least partially throttled position, unless the controllable valve is already in said position; wherein the predetermined criterion is that: - the oil temperature at the downstream end of the first supply conduit is above a predetermined temperature threshold, - the electrical machine is operated above an upper power threshold, and - the rotational speed of the electrical machine is within a predetermined rotational speed interval, said predetermined rotational speed interval being defined by a lower rotational speed threshold and an upper rotational speed threshold. in response to a determination that a predetermined criterion is fulfilled, controlling the controllable valve to an at least partially throttled position, unless the controllable valve is already in said position; wherein the predetermined criterion is that: - the oil temperature at the downstream end of the first supply conduit is above a predetermined temperature threshold, - the electrical machine is operated above an upper power threshold, and - the rotational speed of the electrical machine is within a predetermined rotational speed interval, said predetermined rotational speed interval being defined by a lower rotational speed threshold and an upper rotational speed threshold. - the oil temperature at the downstream end of the first supply conduit is above a predetermined temperature threshold, - the electrical machine is operated above an upper power threshold, and - the rotational speed of the electrical machine is within a predetermined rotational speed interval, said predetermined rotational speed interval being defined by a lower rotational speed threshold and an upper rotational speed threshold.