The 29-year-old made 27 appearances for the Millers since joining from Bristol City in January 2017 and leaves for an undisclosed fee.
“Richard is an excellent keeper who has extensive experience of playing in the Championship and League One,” said manager Jimmy Floyd Hasselbaink.
“He has over 250 appearances under his belt and he is a good age for a keeper.
“Richard has a great attitude, he will be one of the leaders and a good influence in the dressing room and I am sure he will do well for us.”
O’Donnell was signed by the Millers last January but failed to convince boss Paul Warne with some inconsistent performances.
His arrival at Sixfields means loanee Matt Ingram returns to QPR.
“Matt has done really well for us and we would like to thank him for his efforts,” said Hasselbaink.
Rangers manager Steven Gerrard is weighing up a move for Liverpool full-back Jon Flanagan, reports claim.
Scottish champions Celtic are reportedly ready to offer full-back Calvin Miller a new deal before sending him out on loan.
Everton target Jack Wilshere has sparked a scramble for his signature after confirming he is leaving Arsenal this summer.
Tottenham's hopes of landing Wilfried Zaha have been hit by the news Crystal Palace have offered him a bumper new deal to stay.
Ryan Giggs says Gareth Bale would be the perfect fit for Manchester United but has doubts over whether he will leave Real Madrid.
Manchester City's attempts to sign Riyad Mahrez could be in doubt again as reports claim Leicester only want a straight cash deal.