odoo/upgrade-util#295

Created by Upgrade, Carsten Wolff (cawo)
Merged at 025b234313af3b51c1eee739e2cdffd69709c978

Statuses:

Linked pull requests
label
odoo-dev:master-imp_make_pickleable_callback_preserve_same_file-cawo
head
b45dfb9eb871716db63273400d49acaadd779fa5
merged
2 days ago by Upgrade, Christophe Simonis (chs)
odoo/upgrade odoo/upgrade-util
master #8047 #295

[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.