Does Quantum Theory allow an Electron to take a fraction of Photon energy

There is a simple reason why a free election can't absorb a photon completely: you can't conserve both energy and momentum for the system of you start off with an electron and a photon and and up with only an electron. You need a final photon as well for conservation of energy and momentum to be satisfied.

For the photoelectric effect things are different. We don't have a free electron ; it is bound to a nucleus. Consequently it can only have certain precise energy values (and won't interact with photons that would move it to a non existent energy level, which is the basic argument for quantum behaviour, but not really comparable to Compton scattering).

In the situation analagous to Compton scattering, the photon has more energy than the binding energy of the electron, and so we wind up with a free electron. But in this case energy and momentum can be conserved without a final photon since the nucleus is also involved in the interaction. The initial state is {photon, bound electron, nucleus } and the final state {free electron, nucleus}.

It is possible to construct Feynman diagrams with a final photon present too, but since they have an extra vertex they happen less often by a factor of roughly the fine structure constant $\alpha\sim\frac{1}{137}.$

Or to put it another way, sometimes in the photoelectric effect where you end up with a free electron you do get a final photon, but it is in less than 1% of cases (unless I've overlooked some reason why it can't happen).

I still don't get whether the electrons are allowed to take the energy of the whole photon when they are in energy levels and can they absorb a fraction of the photon energy when they are free

Electrons may be free, or bound within an atom due to the relative potential between the nucleus and the electron, for a simple case, i.e. the hydrogen atom.

When bound in an atom a photon with an exact energy difference ( within the width) to the ionization level can be completely absorbed by the atomic system and an electron will go free and the atom will recoil. This kinematically is a two body situation. Before it is "photon + atom" after "electron + atom". There exists a physical center of mass system.

In two body interactions energy and momentum are conserved by the end particles, in this case an ionized atom and an electron.

When an electron is free , as in compton scattering, the system is "Photon1 + electron" as initial state, and the final state is "photon2+electron" There exists a consistent physical center of mass system in both cases.

Energy and momentum are conserved from initial to final state.

If photon2 is a zero vector, the initial center of mass will have the invariant mass of "photon1+electron" which will be larger than just the mass of the electron, and the final one will have just the invariant mass of the electron. This is inconsistent with energy conservation and cannot be physical.

And how energy and Momentum will not be conserved when the bound electron is hit by a photon of energy less than the energy difference between any two consecutive cells and then the electron gets out of its shell

In quantum mechanics, the atom is a bound system to which energy can be given in quanta, corresponding to the energy levels.

If the transition is "Photon + atom" going to "excited atom", i.e. the electron changed energy level, energy is conserved because now the atom has more energy, the one the photon gave up. In the center of mass before, momentum is zero, and after momentum is zero and the energy before is equal to the energy after because the atom is at an excited level carrying the photon energy.

The case of photon +electron ---> electron cannot conserve energy, because at the center of mass there is the energy of the photon +the energy of the mass of the electron, incoming, but only the energy of the mass of the electron outgoing, the electron does not have quantum mechanical excited states to increase its rest mass energy, as the excited atom does.