Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8645077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:27:26+00:00 2026-06-12T12:27:26+00:00

The OpenERP python code development cycle is to edit your code, restart the server

  • 0

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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:27:27+00:00Added an answer on June 12, 2026 at 12:27 pm

    UPDATE: since v8 the Odoo server provides an --auto-reload option to perform this.

    Excellent question, I’ve often wondered the same. I think the main problem with the code you posted is that it only reloads the OpenERP module’s __init__.py file, not all the individual files. The reimport module recommended by ecatmur takes care of that, and I also had to unregister the module’s report parsers and model classes before reloading everything.

    I’ve posted my module_reload module on Launchpad. It seems to work for changes to model classes, osv_memory wizards, and report parsers. It does not work for old-style wizards, and there may be other scenarios that don’t work.

    Here’s the method that reloads the module.

    def button_reload(self, cr, uid, ids, context=None):
        for module_record in self.browse(cr, uid, ids, context=context):
            #Remove any report parsers registered for this module.
            module_path = 'addons/' + module_record.name
            for service_name, service in Service._services.items():
                template = getattr(service, 'tmpl', '')
                if template.startswith(module_path):
                    Service.remove(service_name)
    
            #Remove any model classes registered for this module
            MetaModel.module_to_models[module_record.name] = []                    
    
            #Reload all Python modules from the OpenERP module's directory.
            modulename = 'openerp.addons.' + module_record.name
            root = __import__(modulename)
            module = getattr(root.addons, module_record.name)
    
            reimport(module)
        RegistryManager.delete(cr.dbname)
        RegistryManager.new(cr.dbname)
        return {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to insert customer details into OpenERP server using XMLPRC and java.
Why isn't this simple Python code working? import urllib file = urllib.urlopen('http://www.google.com') print file.read()
I have a python script that makes a series of url calls using urllib2.
I have code which issues many HTTP GET requests using Python's urllib2, in several
I'm new to python and I'm writing a code to upload a file using
I'm using the following code from the bool Hello! Python: import urllib2 from bs4
I'm new to OpenERP and Python, I'm trying to understand the various functions in
I'm trying to code a python google api. Getting some unicode issues. My really
Under Python 3.1, when trying to run this code: from urllib import request def
I have Python code to call a REST service that is something like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.