Port of https://code.launchpad.net/~camptocamp/openobject-addons/7.0-fix_1220716-rha+srt+afe,
which should be the remaining part of http://bazaar.launchpad.net/~ocb/ocb-addons/7.0/revision/9628
after the merge of http://bazaar.launchpad.net/~openerp/openobject-addons/7.0/revision/9651

Original code by Rifakat Husen. Original conflict resolving by Stefan Rijnhart. Post-conflict refactoring
by Alexandre Fayolle.