Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
7 Răspunsuri
41853 Vizualizări

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
Imagine profil
Abandonează

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

Autor

inside models folder

Cel mai bun răspuns

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

 

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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>

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
aug. 18
11677
0
oct. 19
4339
2
ian. 25
1163
4
oct. 22
23969
3
iul. 20
8859