mirror of https://github.com/OCA/web.git
[IMP] web_advanced_search: black, isort
parent
eb9678e71d
commit
2ade029763
|
@ -5,23 +5,15 @@
|
|||
|
||||
{
|
||||
"name": "Advanced search",
|
||||
"version": "12.0.1.0.2",
|
||||
"author": "Therp BV, "
|
||||
"Tecnativa, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"version": "13.0.1.0.0",
|
||||
"author": "Therp BV, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"category": "Usability",
|
||||
"summary": "Easier and more powerful searching tools",
|
||||
"website": "https://github.com/OCA/web",
|
||||
"depends": [
|
||||
'web',
|
||||
],
|
||||
"data": [
|
||||
'views/templates.xml',
|
||||
],
|
||||
"qweb": [
|
||||
'static/src/xml/web_advanced_search.xml',
|
||||
],
|
||||
"depends": ["web"],
|
||||
"data": ["views/templates.xml"],
|
||||
"qweb": ["static/src/xml/web_advanced_search.xml"],
|
||||
"installable": True,
|
||||
"application": False,
|
||||
}
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
DomainTree: function() {
|
||||
var human_domains = [];
|
||||
_.each(this.children, function(child) {
|
||||
human_domains.push(
|
||||
human_domain_methods[child.template].apply(child)
|
||||
);
|
||||
human_domains.push(human_domain_methods[child.template].apply(child));
|
||||
});
|
||||
return _.str.sprintf(
|
||||
"(%s)",
|
||||
|
@ -41,10 +39,8 @@
|
|||
// Humanize chain
|
||||
this.chain.split(".").forEach(function(element, index) {
|
||||
chain.push(
|
||||
_.findWhere(
|
||||
this.fieldSelector.pages[index],
|
||||
{name: element}
|
||||
).string || element
|
||||
_.findWhere(this.fieldSelector.pages[index], {name: element})
|
||||
.string || element
|
||||
);
|
||||
}, this);
|
||||
// Special beautiness for some values
|
||||
|
@ -54,27 +50,17 @@
|
|||
} else if (_.isArray(this.value)) {
|
||||
value = _.str.sprintf('["%s"]', this.value.join('", "'));
|
||||
}
|
||||
return _.str.sprintf(
|
||||
"%s %s %s",
|
||||
chain.join("→"),
|
||||
operator || this.operator,
|
||||
value
|
||||
).trim();
|
||||
return _.str
|
||||
.sprintf("%s %s %s", chain.join("→"), operator || this.operator, value)
|
||||
.trim();
|
||||
},
|
||||
};
|
||||
|
||||
function getHumanDomain(parent, model, domain, options) {
|
||||
var domain_selector = new DomainSelector(
|
||||
parent,
|
||||
model,
|
||||
domain,
|
||||
options
|
||||
);
|
||||
var domain_selector = new DomainSelector(parent, model, domain, options);
|
||||
var dummy_parent = $("<div>");
|
||||
domain_selector.appendTo(dummy_parent);
|
||||
var result = human_domain_methods.DomainSelector.apply(
|
||||
domain_selector
|
||||
);
|
||||
var result = human_domain_methods.DomainSelector.apply(domain_selector);
|
||||
domain_selector.destroy();
|
||||
dummy_parent.destroy();
|
||||
return result;
|
||||
|
|
|
@ -18,7 +18,7 @@ odoo.define("web_advanced_search", function (require) {
|
|||
|
||||
SearchView.include({
|
||||
custom_events: _.extend({}, SearchView.prototype.custom_events, {
|
||||
"get_dataset": "_on_get_dataset",
|
||||
get_dataset: "_on_get_dataset",
|
||||
}),
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,6 @@ odoo.define("web_advanced_search", function (require) {
|
|||
* An almost dummy search proposition, to use with domain widget
|
||||
*/
|
||||
var AdvancedSearchProposition = Widget.extend({
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
|
@ -76,7 +75,7 @@ odoo.define("web_advanced_search", function (require) {
|
|||
// Add advanced search features
|
||||
FiltersMenu.include({
|
||||
custom_events: _.extend({}, FiltersMenu.prototype.custom_events, {
|
||||
"domain_selected": "advanced_search_commit",
|
||||
domain_selected: "advanced_search_commit",
|
||||
}),
|
||||
|
||||
events: _.extend({}, FiltersMenu.prototype.events, {
|
||||
|
@ -154,9 +153,7 @@ odoo.define("web_advanced_search", function (require) {
|
|||
FieldManagerMixin.init.call(this);
|
||||
this.trigger_up("get_dataset");
|
||||
// Make equal and not equal appear 1st and 2nd
|
||||
this.operators = _.sortBy(
|
||||
this.operators,
|
||||
function (op) {
|
||||
this.operators = _.sortBy(this.operators, function(op) {
|
||||
switch (op.value) {
|
||||
case "=":
|
||||
return -2;
|
||||
|
@ -194,11 +191,7 @@ odoo.define("web_advanced_search", function (require) {
|
|||
params.fieldsInfo.default[this.field.name] = {};
|
||||
// Emulate `model.load()`, without RPC-calling `default_get()`
|
||||
this.datapoint_id = this.model._makeDataPoint(params).id;
|
||||
this.model.applyDefaultValues(
|
||||
this.datapoint_id,
|
||||
{},
|
||||
params.fieldNames
|
||||
);
|
||||
this.model.applyDefaultValues(this.datapoint_id, {}, params.fieldNames);
|
||||
// To generate a new fake ID
|
||||
this._fake_id = -1;
|
||||
},
|
||||
|
@ -279,7 +272,7 @@ odoo.define("web_advanced_search", function (require) {
|
|||
* @override
|
||||
*/
|
||||
_applyChanges: function(dataPointID, changes, event) {
|
||||
if (this._field_widget_name === 'many2one') {
|
||||
if (this._field_widget_name === "many2one") {
|
||||
// Make char updates look like valid x2one updates
|
||||
if (_.isNaN(changes[this.field.name].id)) {
|
||||
changes[this.field.name] = {
|
||||
|
@ -332,12 +325,12 @@ odoo.define("web_advanced_search", function (require) {
|
|||
default:
|
||||
return this._field_widget.$el.val();
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
} catch (error) {
|
||||
if (error.name === "TypeError") {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
<!-- Copyright 2017-2018 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_advanced_search/static/src/js/human_domain.js"/>
|
||||
<script type="text/javascript" src="/web_advanced_search/static/src/js/web_advanced_search.js"/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_advanced_search/static/src/js/human_domain.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_advanced_search/static/src/js/web_advanced_search.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
|
|
Loading…
Reference in New Issue