6

Why the below code is not working for odoo 9 but its working for odoo 8...

openerp.petstore = function(instance, local) {

    instance.web.form.widgets = instance.web.form.widgets.extend(
    {
        'test' : 'instance.web.form.message',
    });

    instance.web.form.message = instance.web.form.FieldChar.extend(
    {
        template: 'test',
        start: function() {
        alert('working');
       }
    });
}
Naglis
  • 2,583
  • 1
  • 19
  • 24
Mani
  • 2,675
  • 2
  • 20
  • 42

2 Answers2

0

Have you tried:

openerp.oepetstore = function(instance, local) {

    local.test = instance.Widget.extend({
        start: function() {
            alert('working');
        },
    });

    instance.web.client_actions.add(
        'petstore.test', 'instance.oepetstore.test');
}

Make sure you check the proper version of the documentation because the web client has gone through some major changes.

George Daramouskas
  • 3,720
  • 3
  • 22
  • 51
0

Hello Mr. Mani,

Try this below code,

openerp.oepetstore = function(instance, local) {
    # _t and _lt is use for convert text to python and java script.
    var _t = instance.web._t,
        _lt = instance.web._lt;
    var QWeb = instance.web.qweb;

    local.HomePage = instance.Widget.extend({
        start: function() {
            alert("Hello Mani...");
            console.log("Hello Mani..");
        },
    });

    instance.web.client_actions.add(
        'petstore.homepage', 'instance.oepetstore.HomePage');
}

More information for odoo 9 js read this below best website,
1. https://www.odoo.com/documentation/9.0/howtos/web.htm
2. http://javascript.qahowto.com/Odoo-9-How-to-override-form-widgets-javascript-openerp-qweb-odoo-9-2100c58

I hope my answer is helpful. If any query so comment please.

Mayur Vora
  • 922
  • 2
  • 14
  • 25