Skip to Content
Menu
This question has been flagged
7 Replies
40969 Views

I have installed Odoo 10 on Ubuntu and it works fine

I'm following the tutorial 'building a module' from the Odoo website  

https://www.odoo.com/documentation/10.0/howtos/backend.html#build-an-odoo-module

I have created an empty module with the the command:

odoo-bin scaffold openacademy addons


but when I try to import a module in to the xml file openacademy.xml I get the following error: 


Model not found: openacademy.course
Error context:
View `course.form`[view_id: 4867, xml_id: n/a, model: openacademy.course, parent_id: n/a]None" while parsing /opt/odoo/odoo-10.0/addons/openacademy/views/openacademy.xml:6, near<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>

here is my files:


openacademy.xml:

<?xml version="1.0" encoding="utf-8"?>

<odoo>

<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>  

     </data>

</odoo> 


models.py

from odoo import models, fields, api
class Course(models.Model):
_name = 'openacademy.course'
name = fields.Char(string="Title", required=True)description = fields.Text()


__init__.py

from . import models
Avatar
Discard

where is your models.py file residing path? I mean inside models folder or outside?

Author

inside models folder

Best Answer

just create a module with your code, and it installed smoothly,. .

just change the indent of the models.py.
from odoo import models, fields
class Course(models.Model):
     _name = 'openacademy.course'
     name = fields.Char(string="Title", required=True)
     description = fields.Text("Description")
   

just add a  __manifest__.py file. .

__manifest__.py

{    
    'name': 'test',
    'version': '1.0',
    'category': 'test',
    'description': """test""",
    # 'website': 'https://www.odoo.com/page/accounting',
    'depends': ['base'],
    'data': [ 'openacademy.xml' ],
    'installable': True,
}

 

Avatar
Discard
Best Answer

arrange everything like this and then try,

openacademy/models/models.py

from odoo import models, fields, api
class Course(models.Model):
    _name = 'openacademy.course'
    name = fields.Char(string="Title", required=True)
    description = fields.Text()

openacademy/views/openacademy.xml

<odoo>    
    <data>
        <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>
     
        <menuitem id="main_openacademy_menu" name="Open Academy"/>
        <menuitem id="openacademy_menu" name="Open Academy" parent="main_openacademy_menu"/> 
        <menuitem id="courses_menu" name="Courses" parent="openacademy_menu" action="course_list_action"/>
     </data>
</odoo>

openacademy/__manifest__.py

{
     'name': "Open Academy",
     'author': "My Company",
     'version': '0.1',
     'depends': ['base'],
     'data': [
         'views/openacademy.xml',
     ],
     'demo': []

openacademy/models/__init__.py

from . import models

openacademy/__init__.py

from . import models

I hope this will help you.

Avatar
Discard
Best Answer

You simply need to restart your Odoo server. It will solve the problem.

Avatar
Discard
Best Answer

Have you started the server with the option --dev=all ?

Avatar
Discard
Author Best Answer

I've added the indentation,

added 'views/openacademy.xml' into __manifest__.py

but still the view can't recognize the model !!


ParseError: "Invalid model name u'openacademy.course' in action definition.

None" while parsing /opt/odoo/odoo-10.0/addons/openacademy/views/openacademy.xml:5, 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>

Avatar
Discard
Related Posts Replies Views Activity
2
Aug 18
11141
0
Oct 19
3868
2
Jan 25
780
4
Oct 22
23144
3
Jul 20
8315