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.

1

Creating a new model in the module

By
badr elmar
on 1/15/16, 9:26 AM 961 views

Well, you can understand my problem if you have read the title.

i have used the building module tutorial to develop a new module but when i create a new model (Session model for example), and add a view in my XML, i get an error from the system. 

Best regards,

Hi, please post the complete error traceback, otherwise it will be difficult to help you. Yvan

Yvan
on 1/16/16, 4:58 AM

Traceback (most recent call last): File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 537, in _handle_exception File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 574, in dispatch File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 310, in _call_function File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\service\model.py", line 118, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 307, in checked_call File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 803, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 403, in response_wrap File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\web\controllers\main.py", line 948, in call_button File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\base\module\module.py", line 534, in button_immediate_upgrade File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\base\module\module.py", line 495, in _button_immediate_function File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\registry.py", line 370, in new File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\loading.py", line 351, in load_modules File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\loading.py", line 255, in load_marked_modules File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\loading.py", line 176, in load_module_graph File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\loading.py", line 118, in _load_data File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\tools\convert.py", line 901, in convert_file File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\tools\convert.py", line 987, in convert_xml_import File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\tools\convert.py", line 853, in parse File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\tools\convert.py", line 763, in _tag_record File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\base\ir\ir_model.py", line 1064, in _update File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\base\ir\ir_ui_view.py", line 255, in create File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 360, in old_api File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\models.py", line 4094, in create File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 254, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 496, in new_api File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\models.py", line 4285, in _create File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 254, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\models.py", line 1272, in _validate_fields ParseError: "ValidateError Champ(s) `arch` en erreur vis \xe0 vis de la contrainte : Invalid view definition D\xe9tails de l'erreur : Mod\xe8le introuvable: openacademy.session Contexte de l'erreur : Vue `session.form` [view_id: 337, xml_id: n/a, model: openacademy.session, parent_id: n/a] " while parsing file:///C:/Program Files (x86)/Odoo 8.0-20160106/server/openerp/addons/academy/views/openacademy.xml:77, near session.form openacademy.session This is the error traceback after adding the class Session to the models.py and adding the session view to the XML ; Sessions openacademy.session form tree,form session.form openacademy.session This is the XML added to the XML file.

badr elmar
on 1/16/16, 7:21 AM
1
badr elmar
On 1/16/16, 7:24 AM
It's look like the system don't create the table contact in the database.

What can U propose to resolve that.

Thank U again for your answers.

I think you did not add your .py file into the __init__.py file

Manali Kalariya
on 1/18/16, 12:27 AM

I have already add the .py file last week but it was not working. I am right when i am saying that the reason why i get an error it's that there was no table for the models created in .py file in the DB. Today, i have made a lot of update. Finally, i have got the table created in the DB. Then, i insert the view to XML file. Consequently, IT'S WORKS. I don't know why exactly but the error was generated because there was no table in DB. Thank U very much for your help.

badr elmar
on 1/18/16, 4:47 AM
1
Manali Kalariya
On 1/16/16, 9:03 AM

Hi,

First of all create .py file for the creating model suppose name is contact.py

contact.py

from openerp import fields,models

class contact(models.Model):

_name="contact"

#fields of contact model

name=fields.Char(string="Name",required=True)

nick_name=fields.Char(string="Nick Name")

birth_date=fields.Date(string="Date Of Birth")

==> add this demo.py file into the __init__.py of your particular module

__init__.py

import contact.py

==> now you have to create view for the display this model

contact_view.xml

<openerp>

<data>

<!-- Contact Tree view -->

<record model="ir.ui.view" id="contact_view_tree">

<field name="name">contact.view.tree</field>

<field name="model">contact</field>

<field name="arch" type="xml">

<tree string="tree">

<field name="name"/>

<field name="nick_name"/>

<field name="birth_date"/>

</tree>

</field>

</record>

<record model="ir.ui.view" id="contact_view_form">

<field name="name">contact.view.form</field>

<field name="model">contact</field>

<field name="priority" eval="16"/>

<field name="arch" type="xml">

<form string="form">

<sheet>

<group>

<field name="name"/>

<field name="nick_name"/>

<field name="birth_date"/>

</group>

</sheet>

</form>

</field>

</record>

<!-- Action -->

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

<field name="name">Contact</field>

<field name="res_model">contact</field>

<field name="type">ir.actions.act_window</field>

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

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

</record>

<!-- Contact Menu -->

<menuitem id="contact_menu" action="contact_action" name="Contact" sequence="16"/>

</data>

</openerp>

==> now you have to add the contact_view.xml file into the __opeerp__.py file

__openerp__.py

# -*- coding: utf-8 -*-

{

'name' : 'Contact Module',

'summary' : 'Contact Module',

'version' : '1.0',

'description' : "Contact Module",

'author' : 'Emipro Technologies',

'website' : 'www.emiprotechnologies.com',

'license' : 'AGPL-3',

'category' : 'Uncategorized',

'depends' : [ 'base'],

'data' : [ 'contact_view.xml']

}

==> Restart your Server and update your module list ,Now you can see your view through the Contact menu.

Note :--

Already I'll try your code in my Module it's working proper so I think Error may be an write down wrong Model name or the Wrong Parent Menu name

Thank U for your answer but I get the same error : Traceback (most recent call last): File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 537, in _handle_exception File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 574, in dispatch File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 310, in _call_function File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\service\model.py", line 118, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 307, in checked_call File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 803, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\http.py", line 403, in response_wrap File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\web\controllers\main.py", line 948, in call_button File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\base\module\module.py", line 534, in button_immediate_upgrade File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\base\module\module.py", line 495, in _button_immediate_function File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\registry.py", line 370, in new File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\loading.py", line 351, in load_modules File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\loading.py", line 255, in load_marked_modules File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\loading.py", line 176, in load_module_graph File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\modules\loading.py", line 118, in _load_data File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\tools\convert.py", line 901, in convert_file File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\tools\convert.py", line 987, in convert_xml_import File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\tools\convert.py", line 853, in parse File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\tools\convert.py", line 763, in _tag_record File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\base\ir\ir_model.py", line 1064, in _update File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\openerp\addons\base\ir\ir_ui_view.py", line 255, in create File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 256, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 360, in old_api File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\models.py", line 4094, in create File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 254, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 496, in new_api File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\models.py", line 4285, in _create File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\api.py", line 254, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20160106\server\.\openerp\models.py", line 1272, in _validate_fields ParseError: "ValidateError Champ(s) `arch` en erreur vis \xe0 vis de la contrainte : Invalid view definition D\xe9tails de l'erreur : Mod\xe8le introuvable: contact Contexte de l'erreur : Vue `contact.view.tree` [view_id: 346, xml_id: n/a, model: contact, parent_id: n/a] " while parsing file:///C:/Program Files (x86)/Odoo 8.0-20160106/server/openerp/addons/academy/views/openacademy.xml:79, near contact.view.tree contact

badr elmar
on 1/16/16, 9:42 AM

I am still searching for the solution. if you have more issues to fix this problem, please post all of them. Best regards

badr elmar
on 1/16/16, 2:12 PM

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: 1/15/16, 9:26 AM
Seen: 961 times
Last updated: 1/17/16, 11:19 PM