0
votes

I have installed odoo 10 on linux and it works fine I'm following the official tutorial from odoo website 'building a module'

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

I have created an empty module with

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

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>

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
3
Fix your indentation and why do you have backticks (``) all over the place in your xml code? - danidee
@danidee I've fixed the indentation but still the view doesn't recognize the model - Houssem Abid

3 Answers

0
votes

In the __init__.py just try using

import models
0
votes

try replace this code :

 <field name="name">course.form</field>
 <field name="model">openacademy.course</field>

You can not use "''" in XML, it will cause the error. And then rest some space at the beginning of rows like this

 from odoo import models, fields, api
 class Course(models.Model):
      _name = "openacademy.course"

      name = fields.Char(string="Title", required=True)
      description = fields.Text()
0
votes

Nothing wrong with the sample "building a module" init.py (from https://www.odoo.com/documentation/10.0/howtos/backend.html) it is importing the model under addons/openacademy/models.

In my case, I have to restart odoo (kill the current odoo-bin and restart). The error on importing "openacademy.course" went away, and installation was successful.