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

JQuery Disable/Override Click Event Handler in Odoo9C

By
deep
on 7/19/16, 9:12 AM 381 views

In Odoo 9C, module website_quote.

I would like to override a event handler written in the website_quote, So far I have managed to override standard widgets, but however am not able to override an already overridden widget


Snippet from Standard Module (website_quote.js)

odoo.define('website_quote.website_quote', function (require) {
     'use strict';

     var ajax = require('web.ajax');
     var Widget = require('web.Widget');
     var website = require('website.website');

 // Add to SO button
 var UpdateLineButton = Widget.extend({
    events: {
        'click' : 'onClick',
    },
    onClick: function(ev){
        ev.preventDefault();
        var self = this;
        var href = this.$el.attr("href");
        var order_id = href.match(/order_id=([0-9]+)/);
        var line_id = href.match(/update_line\/([0-9]+)/);
        var token = href.match(/token=(.*)/);

        ajax.jsonRpc("/quote/update_line", 'call', {
            'line_id': line_id[1],
            'order_id': parseInt(order_id[1]),
            'token': token[1],
            'remove': self.$el.is('[href*="remove"]'),
            'unlink': self.$el.is('[href*="unlink"]'),
        }).then(function (data) {
            x;
            if(!data){
                location.reload();
            }
            self.$el.parents('.input-group:first').find('.js_quantity').val(data[0]);
            $('[data-id="total_amount"]>span').html(data[1]);
        });
        return false;
    },
});

var update_button_list = [];
$('a.js_update_line_json').each(function( index ) {
    var button = new UpdateLineButton();
    button.setElement($(this)).start();
    update_button_list.push(button);
});


And In my custom module am trying to override "onClick" function of UpdateLineButton (which is already overridden from Widget). But somehow am not able achieve it.


odoo.define('MyModule.MyModule', function (require) {
     'use strict';

      var webQuote = require('website_quote.website_quote');

      webQuote.UpdateLineButton.include({
              events: {
                 'click' : 'onClick',
                      },

              onClick: function(ev){....}
    });

Any help appreciated. Thanks

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: 7/19/16, 9:12 AM
Seen: 381 times
Last updated: 7/19/16, 9:12 AM