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 insert custom widget in openerp 6.1

By
justeUnPseudo
on 6/25/13, 5:06 AM 2,984 views

I try to insert a custom widget in openERP 6.1.

theme_view.xml:

<?xml version="1.0"?>
<openerp>
    <data>
        <!-- VIEW -->
        <record model="ir.ui.view" id="theme_module_form">
            <field name="name">theme.module.form</field>
            <field name="model">theme.module</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="theme module">
                        <field name="description" colspan="4" widget="test" />
                </form>
            </field>
        </record>
        <!-- ACTIONS -->
        <record model="ir.actions.act_window" id="action_theme_module">
            <field name="name">Aff</field>
            <field name="res_model">theme.module</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
        </record>
        <!--MENU-->
        <menuitem name="Je suis ici" parent="base.menu_config" id="menu_test" action="action_theme_module" />
    </data>
</openerp>

__openerp__.py

{
    'name': "theme module",
    'author': "emisys",
    'category' : 'Outils Emisys',
    'description':'un module',
    'version': "1.0",
    'depends': ['web','base_setup'],
    'css': [ 'static/src/css/resource.css' ],
    'js': [ 'static/src/js/resource.js', 'static/src/js/lib.js', ],
    'qweb' : [  'static/src/xml/resource.xml','static/src/xml/lib.xml',],
    'update_xml': ['theme_view.xml'],
    'installable': True,
    'auto_install': True,
}

resource.js:

 openerp.resource = function (openerp)
{   
    openerp.web.form.widgets.add('test', 'openerp.resource.Mywidget');
    openerp.resource.Mywidget = openerp.web.form.FieldChar.extend(
        {
        template : "test",
        init: function (view, code) {
            this._super(view, code);
            console.log('loading...\n\n\n');
        alert('go javascript')
        }
    });
}

But openerp don't find my widget:

View error Can't find field 'description' in the following view parts composing the view of object model 'theme.module': * theme.module.form

If you have an idea :)

0

Keyur

--Keyur--
1165
| 4 4 8
Ahmedabad, India
--Keyur--

Odoo Expert

Keyur
On 6/25/13, 5:18 AM

Hi!

It is because you have not added description field in your py file. Add description field in theme.module object.

Then it will work properly I guess.

when i add description, i don't see my widget. And as i see in openerp tutorials like sahotaparamjitsingh.blogspot.fr/2012/04/how-to-make-custom-widget-in-openerp.html, normaly it's not necessary.

justeUnPseudo
on 6/25/13, 5:22 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: 6/25/13, 5:06 AM
Seen: 2984 times
Last updated: 3/16/15, 8:10 AM