This question has been flagged
2 Replies
3295 Views

hello,

i am trying o inehrit from js file 'search_inputs_ to change search behavior but it seems that it doesn't works

in my openerp file i eclare my xml view

in my ml view i declare my template whith the path of my js file

and in my js file the beginning is (i want o override get_domain function

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

instance.web.search.Field = iinstance.web.search.Field.extend({
      get_domain: function (facet) {....


maybe the namespace is not good???

thanks a lot by advance


Avatar
Discard
Author Best Answer

hello i have my module name: search_final and the file where ther is the js planning_rh

odoo.define("search_final.planning_rh", function(require){
    "use strict";
    var core = require('web.core');
    var QWeb = core.qweb;
    var SearchView= core.form_common.get('DomainEditorDialog');
    SearchView.include({
        get_domain: function(facet) {
        this._super.apply(this,arguments);
            if (!facet.values.length) { return; }

        var value_to_domain;
        var self = this;
        var domain = this.attrs.filter_domain;
        if (domain) {
            value_to_domain = function (facetValue) {
                return new data.CompoundDomain(domain)
                    .set_eval_context({self: self.value_from(facetValue)});
            };
        } else {
            value_to_domain = function (facetValue) {
                return self.make_domain(
                    self.attrs.name,
                    self.attrs.operator || self.default_operator,
                    facetValue);
            };
        }
        var domains = facet.values.map(value_to_domain);

        if (domains.length === 1) { return domains[0]; }
        for (var i = domains.length; --i;) {
            domains.unshift(['&']);
        }

        return _.extend(new data.CompoundDomain(), {
            __domains: domains
        });
        }
    });

    });

and i have add in xml in web.assets _backend but it still doesnt works

please help me

thanks

Avatar
Discard
Best Answer

Hello brami,

put this code in your .js file to inherite get_domain method in "from_common".

odoo.define("your module name.file name", function(require){
    "use strict";
    var core = require('web.core');
    var QWeb = core.qweb;
    var var_name = core.form_common.get('DomainEditorDialog');
    var_name.include({
        get_domain: function(selected_ids) {
            " Your code "
        },
    });
});


please register this js file in "web.assets_backend".

Hope this will help you, Thanks!

Avatar
Discard