Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
10117 Vizualizări

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!

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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!

Imagine profil
Abandonează

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!

Related Posts Răspunsuri Vizualizări Activitate
4
oct. 20
8601
1
mar. 15
4223
0
mar. 15
4733
0
mar. 15
3559
3
feb. 24
10080