Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

error on custom module install

By
Raquel Jeanne Corpuz Gumtang
on 2/17/14, 12:42 AM 1,760 views

Hi, I'm trying to port custom modules to OpenERP 7 but I am encountering a module trying to import web.common. I understand that this folder is not in v7 anymore. Does anyone know how I can rewrite this module so it can be installed to v7? here is the affected code:

try: # embedded from openerp.addons.web import common import openerp.addons.web.common.http as openerpweb from openerp.addons.web.controllers.main import Reports except ImportError: # standalone from web import common import web.common.http as openerpweb from web.controllers.main import Reports

class custom_class_name(inherited_class_name):

class PrintOutFileName(Reports): # URL defined in addons/custom_module/static/src/views.js _cp_path = "/fs3_web_printout/report"

@openerpweb.httprequest
def index(self, req, action, token):
    action = simplejson.loads(action)

    report_srv = req.session.proxy("report")
    context = req.session.eval_context(
        common.nonliterals.CompoundContext(
            req.context or {}, action[ "context"]))

    report_data = {}
    report_ids = context["active_ids"]
    if 'report_type' in action:
        report_data['report_type'] = action['report_type']
    if 'datas' in action:
        if 'ids' in action['datas']:
            report_ids = action['datas'].pop('ids')
        report_data.update(action['datas'])

I hope you can help me find another way to import what is needed by the code in web.common. Thank you!

0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 2/17/14, 3:38 AM

In V7.0 HttpRequest is under http which is sunder web

.......web.http.HttpRequest

import openerp.addons.web.http as openerpweb (No common)

@openerpweb.HttpRequest (uppercase H and R)

0

thank you for your reply. I tried to change the codes from common to http but I was getting a no handler error. How should I go about changing these lines?

try:

# embedded

from openerp.addons.web import common

import openerp.addons.web.common.http as openerpweb

from openerp.addons.web.controllers.main import Reports

except ImportError:

# standalone

from web import common

import web.common.http as openerpweb

from web.controllers.main import Reports

#and then inside the class:

context = req.session.eval_context( common.nonliterals.CompoundContext( req.context or {}, action[ "context"]))

Which error are yoy getting? which module are you trying to port to v7.0 ? Can you post the content of your openerp-server.log file ?

Med Said BARA
on 2/17/14, 8:43 AM

It seems that the module is from V6.1 !!! Remember there is no "common" under V7.0 http is imported from openerp.addons.web there you can find the class HttpRequest (sorry for the mistake in my Answer -- corrected now).

Med Said BARA
on 2/17/14, 11:05 AM

this is what i get from the log file:

2014-02-18 02:52:18,420 1681 ERROR REL7_TEST openerp: Failed to initialize database REL7_TEST. Traceback (most recent call last): File "/opt/openerp/server/openerp/cli/server.py", line 97, in preload_registry db, registry = openerp.pooler.get_db_and_pool(dbname,update_module=update_module) File "/opt/openerp/server/openerp/pooler.py", line 33, in get_db_and_pool registry = RegistryManager.get(db_name, force_demo, status, update_module) File "/opt/openerp/server/openerp/modules/registry.py", line 203, in get update_module)

Raquel Jeanne Corpuz Gumtang
on 2/17/14, 10:55 PM

File "/opt/openerp/server/openerp/modules/registry.py", line 233, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module) File "/opt/openerp/server/openerp/modules/loading.py", line 350, in load_modules force, status, report, loaded_modules, update_module) File "/opt/openerp/server/openerp/modules/loading.py", line 256, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)

Raquel Jeanne Corpuz Gumtang
on 2/17/14, 10:56 PM

File "/opt/openerp/server/openerp/modules/loading.py", line 159, in load_module_graph load_openerp_module(package.name) File "/opt/openerp/server/openerp/modules/module.py", line 415, in load_openerp_module getattr(sys.modules['openerp.addons.' + module_name], info['post_load'])() File "/opt/openerp/server/openerp/addons/web/http.py", line 628, in wsgi_postload openerp.wsgi.register_wsgi_handler(Root()) File "/opt/openerp/server/openerp/addons/web/http.py", line 517, in __init__ self.load_addons() File "/opt/openerp/server/openerp/addons/web/http.py", line 580, in load_

Raquel Jeanne Corpuz Gumtang
on 2/17/14, 10:57 PM

File "/opt/openerp/server/openerp/modules/module.py", line 133, in load_module mod = imp.load_module('openerp.addons.' + module_part, f, path, descr) File "/opt/openerp/server/openerp/addons/fs3_web_printout _ORIG/__init__.py", line 27, in <module> from . import controllers File "/opt/openerp/server/openerp/addons/fs3_web_printout _ORIG/controllers/__init__.py", line 26, in <module> from . import main File "/opt/openerp/server/openerp/addons/fs3_web_printout _ORIG/controllers/main.py", line 39, in <module> from web import common ImportError: cannot import name common

Raquel Jeanne Corpuz Gumtang
on 2/17/14, 10:57 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 2/17/14, 12:42 AM
Seen: 1760 times
Last updated: 3/16/15, 8:10 AM