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

Can't get past ImportError

By
Lindsay
on 2/3/16, 3:01 PM 831 views

I'm just running through the "Building a Module" documentation for v9 and am following along. My code looks identical to the examples here: https://www.odoo.com/documentation/9.0/howtos/backend.html.

When I start the server this is my error:

2016-02-03 19:54:06,364 3329 INFO ? openerp: OpenERP version 9.0c-20160202

2016-02-03 19:54:06,365 3329 INFO ? openerp: addons paths: ['/home/lslaz/.local/share/Odoo/addons/9.0', u'/home/lslaz/odoo-dev/addons', u'/home/lslaz/odoo-dev/odoo/addons', '/usr/lib/python2.7/dist-packages/openerp/addons']

2016-02-03 19:54:06,365 3329 INFO ? openerp: database: default@default:default

2016-02-03 19:54:06,501 3329 INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069

2016-02-03 19:54:07,397 3329 INFO ? openerp.addons.bus.models.bus: Bus.loop listen imbus on db postgres

2016-02-03 19:54:07,664 3329 INFO ? openerp.addons.report.models.report: You need Wkhtmltopdf to print a pdf version of the reports.

2016-02-03 19:54:07,800 3329 INFO ? openerp.http: HTTP Configuring static files

2016-02-03 19:54:07,806 3329 INFO admin openerp.modules.loading: loading 1 modules...

2016-02-03 19:54:07,813 3329 INFO admin openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries

2016-02-03 19:54:07,841 3329 INFO admin openerp.modules.loading: loading 15 modules...

2016-02-03 19:54:07,844 3329 INFO admin passlib.registry: registered crypt handler 'pbkdf2_sha512': <class 'passlib.handlers.pbkdf2.pbkdf2_sha512'>

2016-02-03 19:54:07,847 3329 INFO admin passlib.registry: registered crypt handler 'md5_crypt': <class 'passlib.handlers.md5_crypt.md5_crypt'>

2016-02-03 19:54:07,856 3329 CRITICAL admin openerp.modules.module: Couldn't load module openacademy

2016-02-03 19:54:07,856 3329 CRITICAL admin openerp.modules.module: cannot import name models

2016-02-03 19:54:07,857 3329 ERROR admin openerp.modules.registry: Failed to load registry

Traceback (most recent call last):

File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 385, in new

openerp.modules.load_modules(registry._db, force_demo, status, update_module)

File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 334, in load_modules

force, status, report, loaded_modules, update_module)

File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 237, in load_marked_modules

loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)

File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 123, in load_module_graph

load_openerp_module(package.name)

File "/usr/lib/python2.7/dist-packages/openerp/modules/module.py", line 324, in load_openerp_module

__import__('openerp.addons.' + module_name)

File "/usr/lib/python2.7/dist-packages/openerp/modules/module.py", line 61, in load_module

mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)

File "/home/lslaz/odoo-dev/addons/openacademy/__init__.py", line 2, in <module>

from . import models

ImportError: cannot import name models

2016-02-03 19:54:07,858 3329 INFO admin werkzeug: 127.0.0.1 - - [03/Feb/2016 19:54:07] "POST /web/webclient/version_info HTTP/1.1" 500 -

2016-02-03 19:54:07,876 3329 ERROR admin werkzeug: Error on request:

Traceback (most recent call last):

File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi

execute(self.server.app)

File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute

application_iter = app(environ, start_response)

File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 245, in app

return self.app(e, s)

File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 184, in application

return application_unproxied(environ, start_response)

File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 170, in application_unproxied

result = handler(environ, start_response)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1488, in __call__

return self.dispatch(environ, start_response)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1462, in __call__

return self.app(environ, start_wrapped)

File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__

return self.app(environ, start_response)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1637, in dispatch

ir_http = request.registry['ir.http']

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 360, in registry

return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None

File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 354, in get

update_module)

File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 385, in new

openerp.modules.load_modules(registry._db, force_demo, status, update_module)

File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 334, in load_modules

force, status, report, loaded_modules, update_module)

File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 237, in load_marked_modules

loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)

File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 123, in load_module_graph

load_openerp_module(package.name)

File "/usr/lib/python2.7/dist-packages/openerp/modules/module.py", line 324, in load_openerp_module

__import__('openerp.addons.' + module_name)

File "/usr/lib/python2.7/dist-packages/openerp/modules/module.py", line 61, in load_module

mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)

File "/home/lslaz/odoo-dev/addons/openacademy/__init__.py", line 2, in <module>

from . import models

ImportError: cannot import name models

^C2016-02-03 19:54:08,626 3329 INFO ? openerp.service.server: Initiating shutdown

2016-02-03 19:54:08,626 3329 INFO ? openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown.


If I delete the "from . import models" from the init.py I get a different error:

ParseError: "Invalid model name in the action definition.

None" while parsing /home/lslaz/odoo-dev/addons/openacademy/views/views.xml:8, near

<record model="ir.actions.act_window" id="course_list_action">

<field name="name">Courses</field>

<field name="res_model">openacademy.course</field>

<field name="view_type">form</field>

<field name="view_mode">tree,form</field>

<field name="help" type="html">

<p class="oe_view_nocontent_create">Create the first course

</p>

</field>

</record>


Please help! I'm confident that both there things are as they should be but I can't move forward until I figure out what the problem is.

1

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 2/4/16, 1:35 AM

Hi,

Check that you've really folder with name 'models', and there is __init__.py inside of it. can you write down your directory structure ?

It seems that something missing inside of models directory ...

0
Tech Support
On 2/29/16, 9:28 AM

@Benoît Vézina

I simply had no luck trying it the way you described. Any time I created an __init__.py in models/ to import each model and then from . import models in the top level __init__.py I would get this ImportError.

The only way I found around this was to from . import models in the top level __init__.py and move the models.py out of models/ and make it a sibling to __init__.py. Then, no problem!

This is DEFINITELY NOT ideal but it's all I could do to make it work...

If you find the correct workaround I would appreciate knowing how you did it!

0
Benoît Vézina
On 2/28/16, 1:07 PM

Having same kind of problems here trying to follow (with minimal change) the OpenAcademy examples. My problems start when I had the second model (Session).

Error details:
Model not found: xtremmod.session

but in the main __init__.py 

from . import models

And it the models folder I have in my __ init__.py

from . import course 
from . import session

And then in models/session.py

from openerp import models, fields, api
class Session(models.Model)

_name = 'xtremmod.session'
name = fields.Char(required=True)
start_date = fields.Date()
duration = fields.Float(digits=(6, 2), help="Duration in days")
seats = fields.Integer(string="Number of seats")
instructor_id = fields.Many2one('res.partner', string="Instructor")
course_id = fields.Many2one('xtremmod.course',

ondelete='cascade', string="Course", required=True)

attendee_ids = fields.Many2many('res.partner', string="Attendees")

and I get the following error while import module

Model not found: xtremmod.session

Removing (by commenting) session form view; session tree/list view; the next action (session_list_action) and the menuitem session_menu make it install and course part work fine 

<field name="model">xtremmod.session</field>

This is the xml call that make the install crash...

Any help welcome

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

1 follower(s)

Stats

Asked: 2/3/16, 3:01 PM
Seen: 831 times
Last updated: 2/29/16, 9:28 AM