Does someone have to have perfect morality or sila in order to be reborn in a heavenly realm? If yes, could someone provide the source?
No. A person does not need to have perfect morality to be reborn in a heavenly realm. The quote below should be self-explanatory.
From MN 136:
"Now there is the person who has killed living beings here... has had wrong view. And on the dissolution of the body, after death, he reappears in a happy destination, in the heavenly world. But (perhaps) the good kamma producing his happiness was done by him earlier, or the good kamma producing his happiness was done by him later, or right view was undertaken and completed by him at the time of his death. And that was why, on the dissolution of the body, after death, he reappeared in a happy destination, in the heavenly world. But since he has killed living beings here... has had wrong view, he will feel the result of that here and now, or in his next rebirth, or in some subsequent existence.
If not wishing to fall into bad destinations afterwards again, yes.
It's like if asking, "Can a thief or murder spend some times like in heaven, on the beach?", sure it might, but how long would his pleasure last?
Therefore the wise recomment in this ways, ways of similies:
Once we've abandoned doing evil, then even when we make merit only a bit at a time, there's still hope that our perfections will grow full. Like a basin set upright out in the open: Even if rain falls only a drop at a time, there's a chance that the basin will get full.
But if we make merit without abandoning evil, it's like putting a basin upside-down out in the open. When the rain falls it still lands on the bottom of the basin, but on the outside bottom, not on the inside. There's no way the water will fill the basin.
And it's not out of reason that real generosity is actually counted as a quality just possessed by virtuous and wise.
Leaving the realms of the Devas, they will encourage, so hear their calls:
The devas, knowing from this that 'This deva-son is about to pass away,' encourage him with three sayings: 'Go from here, honorable sir, to a good destination. Having gone to a good destination, gain the gain that is good to gain. Having gained the gain that is good to gain, become well-established.'"
[Note: This is a gift of Dhamma and not meant for use of commercial purposes and other wordily gains by trade and exchange, but intended and bound to good destiny, awakening and liberation, and so good if shared likewise.]