[MIG] web_widget_domain_editor_dialog: Migration to v13.0

This commit is contained in:
Carlos Roca
2020-10-08 14:50:55 +02:00
committed by Carlos Lopez
parent ec8afdada7
commit e2ca17b342
6 changed files with 48 additions and 67 deletions

View File

@@ -4,19 +4,19 @@
odoo.define("web_widget_domain_editor_dialog.basic_fields", function(require) {
"use strict";
var core = require("web.core");
var basic_fields = require("web.basic_fields");
var DomainEditorDialog = require("web_widget_domain_editor_dialog.DomainEditorDialog");
var _t = core._t;
const core = require("web.core");
const basic_fields = require("web.basic_fields");
const DomainEditorDialog = require("web_widget_domain_editor_dialog.DomainEditorDialog");
const _t = core._t;
basic_fields.FieldDomain.include({
_onShowSelectionButtonClick: function(event) {
event.preventDefault();
var _this = this;
const _this = this;
if (this.mode === "readonly") {
return this._super.apply(this, arguments);
}
var dialog = new DomainEditorDialog(this, {
const dialog = new DomainEditorDialog(this, {
title: _t("Select records..."),
res_model: this._domainModel,
default_domain: this.value,

View File

@@ -4,65 +4,43 @@
odoo.define("web_widget_domain_editor_dialog.DomainEditorDialog", function(require) {
"use strict";
var core = require("web.core");
var view_dialogs = require("web.view_dialogs");
var SearchView = require("web.SearchView");
var _t = core._t;
const core = require("web.core");
const view_dialogs = require("web.view_dialogs");
const Domain = require("web.Domain");
const _t = core._t;
var DomainEditorDialog = view_dialogs.SelectCreateDialog.extend({
const DomainEditorDialog = view_dialogs.SelectCreateDialog.extend({
init: function() {
this._super.apply(this, arguments);
var _this = this;
const _this = this;
this.options = _.defaults(this.options, {
initial_facet: {
category: _t("Custom Filter"),
icon: "fa-circle",
field: {
get_context: function() {
return _this.options.context;
},
get_groupby: function() {
return [];
},
get_domain: function() {
return _this.options.default_domain;
},
dynamicFilters: [
{
description: _.str.sprintf(_t("Selected domain")),
domain: Domain.prototype.stringToArray(
_this.options.default_domain
),
},
values: [{label: _t("Selected domain"), value: null}],
},
],
});
},
start: function() {
var search_view = _.find(this.getChildren(), function(x) {
return x instanceof SearchView;
});
if (this.options.initial_facet && search_view) {
search_view.query.reset([this.options.initial_facet], {
preventSearch: true,
});
search_view.do_search();
}
this._super.apply(this, arguments);
},
get_domain: function(selected_ids) {
var group_domain = [];
var search_data = this.list_controller.renderer.state;
var domain = search_data.domain;
let group_domain = [];
const search_data = this.viewController.renderer.state;
let domain = search_data.domain;
if (this.$(".o_list_record_selector input").prop("checked")) {
if (search_data.groupedBy.length) {
group_domain = _.filter(search_data.data, function(x) {
group_domain = _.filter(search_data.data, x => {
return x.res_ids.length;
}).map(function(x) {
}).map(x => {
return x.domain;
});
group_domain = _.flatten(group_domain, true);
// Compute domain difference
_.each(domain, function(d) {
_.each(domain, d => {
group_domain = _.without(
group_domain,
_.filter(group_domain, function(x) {
_.filter(group_domain, x => {
return _.isEqual(x, d);
})[0]
);
@@ -76,7 +54,7 @@ odoo.define("web_widget_domain_editor_dialog.DomainEditorDialog", function(requi
).concat(group_domain);
}
} else {
var ids = selected_ids.map(function(x) {
const ids = selected_ids.map(x => {
return x.id;
});
domain = domain.concat([["id", "in", ids]]);
@@ -84,7 +62,7 @@ odoo.define("web_widget_domain_editor_dialog.DomainEditorDialog", function(requi
return domain.concat(group_domain);
},
on_view_list_loaded: function() {
on_view_list_loaded: () => {
this.$(".o_list_record_selector input").prop("checked", true);
this.$footer
.find(".o_selectcreatepopup_search_select")