[FIX] tools,mail: improve parsing of references from rev. 0bee015dd67cb809fd235215b43d331074824e42

Backport of 8.0 fix was not enough for 7.0, because it still fails for the legacy reference match (model+res_id), which is not used in 8.0
Merge branch '7.0' of https://github.com/odoo/odoo into 7.0-linux64