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

I'm new to openerp, and try to build a web module by following doc.openerp.com/trunk/web/module/ step by step, now the problem is when I began to change action to instance.web.Widget.extend

instance.web_example.Action = instance.web.Widget.extend({
    className: 'oe_web_example',
    start: function () {
        // this.$el.text("Hello, world!");
        console.log("Executed the action", action);
        return this._super();
    }
});

when I click the menu i got this error , TypeError: ClientWidget is null, I double checked the javascript file and __openerp__.py which is exactly identical to the document.

The database was clean and no other module installed but this one.

Any one any idea?

Imagine profil
Abandonează
Cel mai bun răspuns

Following doc.openerp.com/trunk/web/module/ the below Code will works:-

web_example/web_example.xml

<openerp>
    <data>
        <record model="ir.actions.client" id="action_client_example">
            <field name="name">Example Client Action</field>
            <field name="tag">example.action</field>
        </record>
        <menuitem action="action_client_example"
                  id="menu_client_example"/>
    </data>
</openerp>

static/src/js/first_module.js

openerp.web_example = function (instance) {
  instance.web.client_actions.add('example.action', 'instance.web_example.Action');
instance.web_example.Action = instance.web.Widget.extend({
    className: 'oe_web_example',
    start: function () {
         this.$el.text("Hello, world!");
        //console.log("Executed the action", action); Action is not defined
        return this._super();
    }
});
};
Imagine profil
Abandonează
Autor

Thanks man. you known I just change one line of code which you comment it out, that because this.$el.text("Hello, world!") got same error. and if I change the instance.web_example.Action = function(...... , it works. BTW, I restart the server and refresh browser.

Autor

Finally sort it out, there is a inconsistent typing in the tutorial, previous one is instance.web.client_actions.add('example.action', 'instance.web_example.action', next step is instance.web.client_actions.add('example.action', 'instance.web_example.Action', thanks for the help anyway.

Related Posts Răspunsuri Vizualizări Activitate
2
iul. 25
1280
1
mai 25
796
2
mai 25
1387
0
oct. 24
1080
1
iul. 24
3026