I believe this is from the Messenger of Allah ﷺ, who said, "When one of you prays without a barrier in front of him, his prayer is broken by a dog, a donkey, a pig, a Jew, a Magian, or a woman passing in front of him. It suffices him if they pass at a distance of a stone's throw."
حدثنا محمد بن إسمعيل مولى بني هاشم البصري حدثنا معاذ حدثنا هشام عن يحيى عن عكرمة
أحسبه عن رسول الله ﷺ قال إذا صلى أحدكم إلى غير سترة فإنه يقطع صلاته الكلب والحمار والخنزير واليهودي والمجوسي والمرأة ويجزئ عنه إذا مروا بين يديه على قذفة بحجر
[Its isnad is daif] Tahawi transmitted it in Maani al-Athar (1/458) from the hadith of Muaz bin Hisham, with the narrator being uncertain about its connection, as he said, "I think," so the chain is flawed.