A deal has been agreed between the UK and the European Union, allowing Brexit negotiations to move on to the next stage.