Odoo Help


How to use a new field added in a inherited model into a view?

Raúl Carpio
on 4/27/16, 2:56 PM 2,173 views

Hello. I am trying to inherit res.partner into a new model, adding a field as suggested in "Creating a model" tutorial. I suppose that a line from the code must be changed to make it work, avoiding the "instructor field does no exist" error: 

instructor = fields.Boolean("Instructor", default=False) 

must be changed for 

_column = {'instructor': fields.Boolean("Instructor", default=False)}

according with a help forum in Odoo. The code for partner.py which does not provoke errors is this:

# -*- coding: utf-8 -*-
from openerp import models, fields, api
class Partner(models.Model):
_inherit = 'res.partner'
# Add a new column to the res.partner model, by default partners are not
# instructors
# instructor = fields.Boolean("Instructor", default=False)
_column = {'instructor': fields.Boolean("Instructor", default=False)}
session_ids = fields.Many2many('openacademy.session',
string="Sesiones Atendidas", readonly=True)

However, when enabling partner.xml to module the error appears again:

ParseError: "Invalid view definition
Error details:
Field `instructor` does not exist
Error context:
View `partner.instructor`

It's code is next:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Add instructor field to existing view -->
<record model="ir.ui.view" id="partner_instructor_form_view">
<field name="name">partner.instructor</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Sesiones">
<field name="instructor"/>
<field name="session_ids"/>
<record model="ir.actions.act_window" id="contact_list_action">
<field name="name">Contacts</field>
<field name="res_model">res.partner</field>
<field name="view_mode">tree,form</field>
<menuitem id="configuration_menu" name="Configuration"
<menuitem id="contact_menu" name="Contacts"

I guess that reference to 'instructor' field in view should be changed somehow to make it clear it does not belong to parent model, but to inherited one. 

Any help would be appreciated. Thanks in advance.

Raúl Carpio
On 4/28/16, 12:05 PM

Thanks, Pawan. I both updated the module and restarted the server. Unfortunately, error appears the same.

Thank for your reply, Akhil. That is the first code I tried. I just returned it according to the way you suggested, and it did not work. I had previously set up two VMs for my tests. I was working in Odoo version 8. After restarting server, along with error at web browser, the log file shows this:

ProgrammingError: column res_partner.instructor does not exist
LINE 1: ...artner"."credit_limit","res_partner"."country_id","res_partn...

However, I did the same in Odoo 9, and it is working fine (!). This somewhat baffling to me, since I had previously tried with that code with no success.

Do you know if Odoo version, 8 or 9, this has something to do with this?

Best regards to both of you.




| 4 4 6
Hyderabad, India

On 4/28/16, 1:17 AM


Try restarting server by upgrading your module(and Db also if you are having multiple DB's)...

Hope it helps!


Akhil P Sivan

--Akhil P Sivan--

| 5 4 7
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 4/28/16, 12:49 AM


You can do the coding either in new api or old api. But here, you are missing them in field definition part which is not in the proper way.

Try like this:

from openerp import models, fields, api
class Partner(models.Model):
    _inherit = 'res.partner'

    instructor = fields.Boolean("Instructor", default=False)
session_ids = fields.Many2many('openacademy.session',string="Sesiones Atendidas", readonly=True)

The tutorial is according to the new api. So please follow like that, because the inheriting classes and libraries are different for them. 

There is nothing wrong with your view definition.

Make sure that you have imported this py file in __init__.py and also added the view file in __openerp__.py

Restart the server n try.

Hope this helps!

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/27/16, 2:56 PM
Seen: 2173 times
Last updated: 4/28/16, 12:05 PM