当字段输入('float','integer','monetary')时,我试图将运算符“between”添加到odoo12ee中。
我正试图覆盖widget domainleaf中的函数_getoperatorsfromtype,但它不起作用,知道吗?
odoo.define('custom_module.DomainLeaf', function(require) {
"use strict";
var DomainLeaf = require("web.DomainSelector");
var Widget = require("web.Widget");
var core = require("web.core");
var _t = core._t;
var _lt = core._lt;
var operator_mapping = {
"=": "=",
"!=": _lt("is not ="),
">": ">",
"<": "<",
">=": ">=",
"<=": "<=",
"ilike": _lt("contains"),
"not ilike": _lt("does not contain"),
"in": _lt("in"),
"not in": _lt("not in"),
"child_of": _lt("child of"),
"parent_of": _lt("parent of"),
"like": "like",
"not like": "not like",
"=like": "=like",
"=ilike": "=ilike",
"between": _lt("is between"),
// custom
"set": _lt("is set"),
"not set": _lt("is not set"),
};
console.log("Module Loaded");
var DomainLeaf = DomainLeaf.include({
template: 'DomainLeaf',
_getOperatorsFromType: function(type) {
var operators = {};
switch (type) {
case "boolean":
operators = {
"=": _t("is"),
"!=": _t("is not"),
};
break;
case "char":
case "text":
case "html":
operators = _.pick(operator_mapping, "=", "!=", "ilike", "not ilike", "set", "not set", "in", "not in");
break;
case "many2many":
case "one2many":
case "many2one":
operators = _.pick(operator_mapping, "=", "!=", "ilike", "not ilike", "set", "not set");
break;
case "integer":
case "float":
case "monetary":
operators = _.pick(operator_mapping, "=", "!=", ">", "<", ">=", "<=", "ilike", "not ilike", "set", "not set", "between");
break;
case "selection":
operators = _.pick(operator_mapping, "=", "!=", "set", "not set");
break;
case "date":
case "datetime":
operators = _.pick(operator_mapping, "=", "!=", ">", "<", ">=", "<=", "set", "not set");
break;
default:
operators = _.extend({}, operator_mapping);
break;
}
if (this.options.operators) {
operators = _.pick.apply(_, [operators].concat(this.options.operators));
}
return operators;
},
});
});
我没有收到任何错误,除了继承函数的行为没有改变外,其他一切都正常。我已将.js文件添加到assets_后端,模块已正确加载,但函数未被覆盖。
暂无答案!
目前还没有任何答案,快来回答吧!