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.

1

Custom Module Issue - Add Field to Event Registration Module

By
Santiago
on 3/12/13, 3:45 AM 2,130 views

Hi!

I created a custom module to add a field to the Event Registration Form, I need a text field where we can input more details for each registered user to an X event.

So far I have develop the following module:

  • add_fields_events (folder)
  • __init__.py
  • __openerp__.py
  • code.py
  • view.xml

Each one with the following simple code:

__init__.py

import code

__openerp__.py

    {
    'name' : 'Custom Extra Event Fields',
    'version' : '1.0',
    'description' : """Custom Extra Fields for Event Module""",
    'depends' : ['event'],
    'init_xml' : [], 
    'update_xml' : ['view.xml'],
    'demo_xml' : [],
    'active' : False, 
    'installable' : True,
}

code.py

from osv import osv, fields

class res_partner_add_text_field(osv.osv):
    _inherit = 'event.registration'

    _columns = {
        'textual_field' : fields.text('Details'),
    }

view.xml

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>            
        <record model="ir.ui.view" id="view_event_form_add_text_field">
            <field name="name">view.event.form.add.text.field</field>
            <field name="model">event.registration</field>
            <field name="inherit_id" ref="view_event_registration_form"/>
            <field name="arch" type="xml">
                <field name="email" position="after">
                    <field name="textual_field" />
                </field>
            </field>
        </record>
    </data>
</openerp>

Everything seems to be alright, but i get the following error when trying to install:

ValueError: No such external ID currently defined in the system: add_event_fields.view_event_registration_form

Any ideas? The "view_event_registration_form" is the id inside of event_view.xml - View which i would like to change.

Thanks in advance!

2
Santiago
On 3/12/13, 4:15 AM

Seems i got the solution.

Reading and watching from other examples I realize that in OpenERP, you have to inherit from the same (folder - file) "structure" that is in the addons folder, so based on that the right parameter in code.py is:

class res_partner_add_text_field(osv.osv):
    _inherit = 'event.event'

In the other hand in the view.xml the "event." property must be included as part of the refence, so the right code would be:

<field name="inherit_id" ref="event.view_event_registration_form"/>

So there you go, my initial experience with custom modules.

Do you have any other advice? Thanks!

No advice for you but your post was instructive to me as I am also a newbie with custom modules. Thanks for the helpful examples!

mike
on 3/12/13, 9:57 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: 3/12/13, 3:45 AM
Seen: 2130 times
Last updated: 3/16/15, 8:10 AM