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

Problem overwriting Odoo Javascript

By
Jose M
on 9/4/14, 4:35 AM 1,006 views

Hello!

Since Odoo minify all JS, if i have two functions with same name, for the same view but in different modules, Odoo will execute the last one minified.

The order of minifying  JS is alphabetical with the name of the module, so in order to execute  the overwritten function I have to name the module after the original, to get my JS the last one in the minified JS file.

An example:

My code

great_project/static/src/js/kanban.js

openerp.great_project = function(instance) {
    var _t = instance.web._t, _lt = instance.web._lt;
    var QWeb = instance.web.qweb;

    instance.web_kanban.KanbanView.include({

        compute_cards_auto_height : function() {
              NEW CODE
        },

    });
};

 

Odoo code

web_kanban/static/src/js/kanban.js

openerp.web_kanban = function (instance) {

var _t = instance.web._t,
   _lt = instance.web._lt;
var QWeb = instance.web.qweb;
instance.web.views.add('kanban', 'instance.web_kanban.KanbanView');

instance.web_kanban.KanbanView = instance.web.View.extend({
    template: "KanbanView",
    display_name: _lt('Kanban'),
    default_nr_columns: 1,
    view_type: "kanban",
    quick_create_class: "instance.web_kanban.QuickCreate",
    number_of_color_schemes: 10,

compute_cards_auto_height: function() {
        if (!this.view.group_by) {
            var min_height = 0;
            var els = [];
            _.each(this.records, function(r) {
                var $e = r.$el.children(':first:not(.oe_kanban_no_auto_height)').css('min-height', 0);
                if ($e.length) {
                    els.push($e[0]);
                    min_height = Math.max(min_height, $e.outerHeight());
                }
            });
            $(els).css('min-height', min_height);
        }
    },

});

}

I dont know if there is a solution to this problem, just want to know what do you do in these cases.

Thank for your time, Jose Maria.

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/4/14, 4:35 AM
Seen: 1006 times
Last updated: 3/16/15, 8:10 AM