The OpenERP python code development cycle is to edit your code, restart the server and test it. Restarting the server is necessary, because it's what makes your source code to be reloaded into memory, but it adds an annoying delay in your work pace.
Since python is such a dynamic language, I wonder if there is a way to force a running python interpreter (the app server ) to reload on the fly a code module, so that it can be tested without restarting the app server?
Update:
Following down the reload
path suggested by @ecatmur, I got the the code below, but it still doesnt work:
class module(osv.osv):
_inherit = "ir.module.module"
def action_reload(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
modulename = 'openerp.addons.' + obj.name
tmp = __import__(modulename)
pycfile = tmp.__file__
modulepath = string.replace(pycfile, ".pyc", ".py")
code=open(modulepath, 'rU').read()
compile(code, modulename, "exec")
execfile(modulepath)
reload( sys.modules[modulename] )
openerp.modules.registry.RegistryManager.delete(cr.dbname)
openerp.modules.registry.RegistryManager.new(cr.dbname)