0
votes

I installed Odoo v8 on my poste windows 7. I created a new module "openacademy" , by following the tutorial "Building a Module" on the official website: https://www.odoo.com/documentation/8.0/howtos/backend.html

then I zip my file "openacademy" ==> "openacademy.zip".

The problem: When I try to import the module, I get this error:

Import Module

WARNING odoo openerp.models: Cannot execute name_search, no _rec_name defined on base.import.module
INFO odoo werkzeug: 127.0.0.1 - - [16/Dec/2014 17:53:03] "POST /web/dataset/call_kw/base.import.module/search_read HTTP/1.1" 200 -
WARNING odoo openerp.modules.module: module openacademy: module not found
INFO odoo openerp.addons.base_import_module.models.ir_module: module openacademy: loading templates.xml
INFO odoo openerp.addons.base_import_module.models.ir_module: module openacademy: loading views/openacademy.xml
INFO odoo werkzeug: 127.0.0.1 - - [16/Dec/2014 17:53:07] "POST /longpolling/poll HTTP/1.1" 200 -
**ERROR odoo openerp.addons.base.ir.ir_ui_view: Model not found: openacademy.course**

Error context:
View 'course.form'
[view_id: 1030, xml_id: n/a, model: openacademy.course, parent_id: n/a]

The model "openacademy.course" is not found, but it already exists in "models.py" !!!

This my code :

models.py :

from openerp import models, fields

class Course(models.Model):

    _name = 'openacademy.course'

    name = fields.Char(string='Title', required=True)
    description = fields.Text()  

views/openacademy.xml :

<openerp>
   <data>
        <record model="ir.ui.view" id="course_form_view">
            <field name="name">course.form</field>
            <field name="model">openacademy.course</field>
            <field name="arch" type="xml">
                <form string="Course Form">
                    <sheet>
                        <group>
                            <field name="name"/>
                            <field name="description"/>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>    
        <!-- window action -->
        <!--
            The following tag is an action definition for a "window action",
            that is an action opening a view or a set of views
        -->
        <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>

        <!-- top level menu: no parent -->
        <menuitem id="main_openacademy_menu" name="Open Academy"/>
        <!-- A first level in the left side menu is needed
             before using action= attribute -->
        <menuitem id="openacademy_menu" name="Open Academy"
                  parent="main_openacademy_menu"/>
        <!-- the following menuitem should appear *after*
             its parent openacademy_menu and *after* its
             action course_list_action -->
        <menuitem id="courses_menu" name="Courses" parent="openacademy_menu"
                  action="course_list_action"/>
        <!-- Full id location:
             action="openacademy.course_list_action"
             It is not required when it is the same module -->
    </data>
</openerp>

__init.py__:

import models 
2
I think you don't need to zip itgoFrendiAsgard

2 Answers

2
votes

Rename your models.py into course.py

course.py :

from openerp import models, fields

class Course(models.Model):

    _name = 'openacademy.course'

    name = fields.Char(string='Title', required=True)
    description = fields.Text() 

And change your __init__.py into this:

import models 

I think model file's name should match the class name. You must make different model for each table.

2
votes

A part from goFrendiAsgard answer, try with this:

  • Run "Update Apps List" in Odoo interface:

    To see this option, you have to turn on the "Technical Feature" going to Settings –> Users, edit your user, and click on "Technical Feature".

  • Restart Odoo server:

    I don't know how to do it in Windows, in Linux is sudo service odoo-server restart

For people facing this issue in a linux environment, can also try:

  • Check your module files and folder have the right owner and group:

    Compare with the rest of modules and change if necesary. For example sudo chown -R odoo:odoo openacademy/

  • Check your module files and folder permissions:

    Usually 755, so you can run sudo chmod -R 755 openacademy/