Skip to Content
Menu
This question has been flagged
1 Reply
5043 Views

Hi


I follow the odoo tutorial  Building a module and I have an issue with the Many2one field.

I got this error


ParseError: "ValidateError

Field(s) `arch` failed against a constraint: Invalid view definition

Error details:

Field `responsible_id` does not exist


when I cheked the model I found out that the field don't exist.

the file openacademy.xml :

<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="responsible_id"/>
                        </group>
                        <notebook>
                            <page string="Description">
                                <field name="description"/>
                            </page>
                            <page string="About">
                                This is an example of notebooks
                            </page>
                        </notebook>
                    </sheet>
                    <search>
                        <field name="name"/>
                        <field name="description"/>
                    </search>
                </form>
            </field>
        </record>


the file models.py :

class Course(models.Model) :
  	 _name = 'openacademy.course'
  	 name = fields.Char(string="Title",required=True)
  	 description = fields.Text()
         responsible_id = fields.Many2one('res.users',
        ondelete='set null', string="Responsible", index=True)



Thank you for the help.

Avatar
Discard
Best Answer

Dear Massi,

I just copy your code in my file, please check the below code

in python file

from openerp import models, fields, api

class Course(models.Model) :

_name = 'openacademy.course'

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

description = fields.Text()

responsible_id = fields.Many2one('res.users', ondelete='set null', string="Responsible", index=True)


in xml file


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

<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="responsible_id"/>

</group>

<notebook>

<page string="Description">

<field name="description"/>

</page>

<page string="About">

This is an example of notebooks

</page>

</notebook>

</sheet>

<search>

<field name="name"/>

<field name="description"/>

</search>

</form>

</field>

</record>

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

<field name="name">course.tree</field>

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

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

<tree>

<field name="name"/>

<field name="responsible_id"/>

</tree>

</field>

</record>

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

<field name="name">Issue</field>

<field name="res_model">openacademy.course</field>

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

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

</record>

<menuitem id="menu_course" action="action_course"></menuitem>

</data>

</openerp>

Above code working fine

Updated Answer

Please check your both files

1. __init__.py

2. __openerp__.py

Cheers,

Ankit H Gandhi.

Avatar
Discard

Nice answer Ankit but it would be much helpful for everyone if you can explain what's wrong with the code.

Thank you @Sudhir Sir for vote me. I didn't change in his code, I just copy that code in my file and define python file in __init__.py file and define xml file in __openerp__.py file