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"?>
<openerp>
<data>
<!-- 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">
<group>
<field name="instructor"/>
<field name="session_ids"/>
</group>
</page>
</notebook>
</field>
</record>
<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>
</record>
<menuitem id="configuration_menu" name="Configuration"
parent="main_openacademy_menu"/>
<menuitem id="contact_menu" name="Contacts"
parent="configuration_menu"
action="contact_list_action"/>
</data>
</openerp>
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.