Avoid permuation of relation type when writing on reverse relation

The relation type must also be permutated.

issue4262
review12641003
(grafted from b0af9f5560e67e6df08927ac4ea1fb106825d2f2)

--HG--
branch : 3.2
extra : source : b0af9f5560e67e6df08927ac4ea1fb106825d2f2