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.

0

Field Many2one not created in database

By
massi
on 4/2/16, 4:38 PM 440 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.

1

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--
996
| 5 3 6
Rajkot, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 4/3/16, 5:49 AM

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.

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

Sudhir Arya (SA)
on 4/3/16, 4:29 PM

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

Ankit H Gandhi(AHG)
on 4/4/16, 6:28 AM

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: 4/2/16, 4:38 PM
Seen: 440 times
Last updated: 4/3/16, 5:49 AM