[FIX] manual import of fix from launchpad lp:~savoirfairelinux-openerp/openobject-...

lp:~savoirfairelinux-openerp/openobject-addons/7.0-bug-1168398-tta+afe+vv

This is an fix to the fix proposed by Tejas Tank, with tests contributed by Alexandre Fayolle and then adapted by myself to show a bug introduced by the fix.