Abu Dawud Book 36, Hadith Number 5173.
Narated By Abdullah Ibn Abbas : Ikrimah said: A group of people from Iraq said: Ibn Abbas, what is your opinion about the verse in which we have been commanded whatever we have been commanded, but no one acts upon it? The word of Allah, Most High, reads: “O ye who believe! Let those whom your right hands possess, and the (children) among you, who have not come of age, ask your permission (before) they enter your presence on three occasions: before morning prayer, while you are undressing for the noonday heat, and after late-night prayer. These are your three times of undress; outside those times it is not wrong for you or for them to move about.”
Al-Qa’nabi recited the verse up to “full of knowledge and wisdom”.
Ibn Abbas said: Allah is Most Clement and Most Merciful to the believers. He loves concealment. The people had neither curtains nor curtained canopies in their houses. Sometimes a servant, a child or a female orphan of a man entered while the man was having sexual intercourse with his wife. So Allah commanded them to ask permission in those times of undress. Then Allah brought them curtains and all good things. But I did not see anyone following it after that.