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.

0

How to add a field to a wizard?

By
Juan Formoso
on 6/23/14, 8:01 AM 1,184 views

I am trying to add a field (only a checkbox) to a wizard. I managed to do exactly this with other form, but it was not a wizard. But I repeated the same steps (obviously changing the respective names and variables) and I cannot see my field in the wizard. I inherited the original wizard as I did with the form which worked, but I do not know if I am doing something stupid, because I have just arrived to OpenERP a few time ago.

The structure of my module is:

my_module
|__ wizard
|   |__ __init__.py
|   |__ wizard_print.py
|
|__ __init__.py
|__ __openerp__.py
|__ my_module_wizard.xml

And my two important files are:

wizard_print.py (in a folder called wizard which has its respective __init__.py too)

from osv import fields, osv

class print_wizard(osv.osv_memory):

    _name = 'my.module.print.wizard'
    _inherit = 'original.module.print.wizard'
    
    _columns = {
        'dummy': fields.boolean('My dummy'),
    }
    _defaults = {
         'dummy': True,
     }

print_wizard()

my_module_wizard.xml (in the main folder with the __openerp__.py and __init__.py)

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="wizard_my_module_print">
            <field name="name">my.module.print.wizard.form</field>
            <field name="model">my.module.print.wizard</field>
            <field name="inherit_id" ref="original_module.wizard_original_module_print"/>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <xpath expr="/form/field[@name='original_variable']" position="after">
                    <newline/>
                    <field name="dummy"/>
                    <newline/>
                </xpath>
            </field>
         </record>
    </data>
</openerp>

Is this structure right? Should it work or is there any mistake I do not know?

Thank you @René Schuster! I removed both: _name from the python declaration and from the XML view. But it does not work yet.

Juan Formoso
on 6/23/14, 10:40 AM

Ok I did not have to delete the field in the XML view! In the XML view I had to change the content of the tag : replace my.module.print.wizard by original.module.print.wizard. I had understood you wrong!

Juan Formoso
on 6/23/14, 12:22 PM
2

René Schuster

--René Schuster--
1560
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 6/23/14, 8:16 AM

If you inherit from an existing model and set a different _name value, an new model will be created.

I think that is not quite what you want.

Change the _name value to "original.module.print.wizard" (in the python declaration and the xml view).

For more information see the Technical Mementos section on different inheritance mechanisms: https://www.odoo.com/files/memento/OpenERP_Technical_Memento_latest.pdf

Or this: http://stackoverflow.com/questions/21111627/inheritance-of-customized-module-in-openerp

 

Regards.

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: 6/23/14, 8:01 AM
Seen: 1184 times
Last updated: 3/16/15, 8:10 AM