Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4513 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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!

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 5 24
2014
1
thg 8 23
11157
5
thg 9 20
32127
1
thg 11 17
11749
1
thg 5 17
4429