odoo/upgrade-util#295

Created by Upgrade, Carsten Wolff (cawo)

Blocked

label
odoo-dev:master-imp_make_pickleable_callback_preserve_same_file-cawo
head
3d69959c494c5244fe24ac5ed107ce56bf2559d2
odoo/upgrade odoo/upgrade-util
master #8047 missing r+ #295 missing r+

[IMP] snippets: preserve same file module

In make_pickleable_callback, when creating a name for the module created via import_script, no longer make the name random, but derive it from the script's path deterministically via a hash function. This way, when this method is called multiple times from the same script for multiple callbacks, it will only import the script once and otherwise re-use the created module. This ensures multiple callbacks from the same script file will run within the same module, seeing e.g. the same values in modified globals, which is much more intuitive.

Also, move the function to misc.py. With the intention to reuse it, it's a better fit. For that, make it python2 compatible.