Anonymous Anonymous - 3 months ago
193 0

No description

Python

Odoo8 - Building a module - inherit - add instructor boolean field - Field `instructor` does not exist

[2] __init__py ,
# -*- coding: utf-8 -*-
from . import controllers
from . import models
from . import partner


[3] __openerp__.py 
# -*- coding: utf-8 -*-
{
    'name': "Open Academy",

    'summary': """Manage trainings""",

    'description': """
            Open Academy module for managing trainings:
                - training courses
                - training sessions
                - attendees registration
        """,

    'author': "Your Company",
    'website': "http://www.yourcompany.com",

    'category': 'Test',
    'version': '0.1',

    'depends': ['base'],

    'data': [
        'templates.xml',
        'views/openacademy.xml',
        'views/partner.xml',
    ],
    'demo': [
        'demo.xml',
    ],
}



[4] partner.py 
# -*- coding: utf-8 -*-
from openerp import fields, models

class Partner(models.Model):
    _name = 'openacademy.partner'
    _inherit = 'res.partner'
    instructor = fields.Boolean("Instructor", default=False)

session_ids = fields.Many2many('openacademy.session',
                               string="Attended Sessions", readonly=True)


[5] partner.xml 
<?xml version="1.0" encoding="UTF-8"?>
 <openerp>
    <data>
        <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="Sessions">
                        <group>
                            <field name="name"/>
                        </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>