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

Why my custom widget is not showing?

By
Anna
on 9/16/14, 12:50 PM 1,493 views

i have followed a tutorial and i added:

static/src/js/resource.js and static/src/xml/resoruce.xml

This is 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...');
        }
    });
}

resource.xml

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="test">
    <html>
        <body>
             <div id="fb-root"></div>
            <div id="fb-root"></div>
            <script>(function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
            fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));</script>
            <div class="fb-like" data-send="true" data-layout="box_count" data-width="600" data-show-faces="false" data-font="arial"></div>
        </body>
    </html>   
</t>
</templates>

__openerp__.py

{
    "name" : "Destin",
    "version" : "0.1",
    "author" : "",
    "category" : "Routes",
    "depends" : ["sale", "fleet", "account"],
    "data" : ['routes_view.xml'],
    "init_xml" : [],
    "js" : ['static/src/js/resource.js'],
    "qweb" : ['static/src/xml/resource.xml'],
    "demo_xml" : [],
    "update_xml" : [],
    "installable": True,
    "active": True
}

But when i try to use it like this in xml view, does not show. It's like doesn't exist:

<record id="view_best_rutas_form" model="ir.ui.view">
                <field name="name">best.route</field>
                <field name="model">best.route</field>
                <field name="priority">1</field>
                <field name="type">form</field>
                <field name="arch" type="xml">
                    <form string="Mejores Rutas" version="7.0">
                        <header>
                            <button name="show_best_route" type="object" string="Calcular orden de entrega" class="oe_highlight"/>             
                        </header>
                        
                            <field name="origen" string="Coordenadas de origen:" widget= "test"/>
                        
                            <field name="invoices" string="Facturas para Enviar" widget="one2many"  colspan="4" nolabel="1">
                                <tree editable="bottom">
                                        <field name="inv_id" domain="[('has_route','=',False), ('has_destination','=',True)]"/>
                                        <field name="order"/>
                                </tree>
                            </field>
                    
                            <field name="fleets" string="Flotas" widget="one2many"  colspan="4" nolabel="1">
                                <tree editable="bottom">
                                    <field name="fleet_id"/>
                                </tree>
                            </field>


                    </form>
                </field>            
           </record>

Does anybody have a clue of why isn't it working?

0

Maniganda

--Maniganda--
1038
| 5 7 7
Bangalore, India
--Maniganda--
Maniganda
On 9/17/14, 1:06 AM

Hi Anna, i would like to know the module name where your js files are stored,

ie. you create js files under resource ---> static --->src ---> js --->resource.js

or

openerp.your_module_name = 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...');
        }
    });
}

 

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: 9/16/14, 12:50 PM
Seen: 1493 times
Last updated: 3/16/15, 8:10 AM