UK dairy processors and farmers have formally agreed a deal on a code of practice to govern relations in the sector.