From 6d68bdad157361442c6eb65a83dd9ae78a25bd7d Mon Sep 17 00:00:00 2001 From: Carlos Roca Date: Thu, 8 Oct 2020 14:50:55 +0200 Subject: [PATCH] [MIG] web_widget_domain_editor_dialog: Migration to v13.0 --- web_widget_domain_editor_dialog/README.rst | 17 ++--- .../__manifest__.py | 2 +- .../readme/CONTRIBUTORS.rst | 5 +- .../static/description/index.html | 13 ++-- .../static/src/js/basic_fields.js | 12 ++-- .../src/js/widget_domain_editor_dialog.js | 66 +++++++------------ 6 files changed, 48 insertions(+), 67 deletions(-) diff --git a/web_widget_domain_editor_dialog/README.rst b/web_widget_domain_editor_dialog/README.rst index d885d11f2..a860c8e4e 100644 --- a/web_widget_domain_editor_dialog/README.rst +++ b/web_widget_domain_editor_dialog/README.rst @@ -14,13 +14,13 @@ Web Widget Domain Editor Dialog :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github - :target: https://github.com/OCA/web/tree/12.0/web_widget_domain_editor_dialog + :target: https://github.com/OCA/web/tree/13.0/web_widget_domain_editor_dialog :alt: OCA/web .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_domain_editor_dialog + :target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_widget_domain_editor_dialog :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/162/12.0 + :target: https://runbot.odoo-community.org/runbot/162/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -57,7 +57,7 @@ with a user filter: You can still edit the filter with Odoo's widget after that. -.. figure:: https://raw.githubusercontent.com/OCA/web/12.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png +.. figure:: https://raw.githubusercontent.com/OCA/web/13.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png :align: center :width: 600 px @@ -67,7 +67,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -84,8 +84,9 @@ Contributors * `Tecnativa `_ - * David Vidal - * Jairo Llopis + * David Vidal + * Jairo Llopis + * Carlos Roca * Darshan Patel @@ -102,6 +103,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/web `_ project on GitHub. +This module is part of the `OCA/web `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_domain_editor_dialog/__manifest__.py b/web_widget_domain_editor_dialog/__manifest__.py index 673c76d5e..34c58cd3b 100644 --- a/web_widget_domain_editor_dialog/__manifest__.py +++ b/web_widget_domain_editor_dialog/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Web Widget Domain Editor Dialog", "summary": "Recovers the Domain Editor Dialog functionality", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "category": "Web", "author": "Tecnativa," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", diff --git a/web_widget_domain_editor_dialog/readme/CONTRIBUTORS.rst b/web_widget_domain_editor_dialog/readme/CONTRIBUTORS.rst index 702999e5b..3621c69b6 100644 --- a/web_widget_domain_editor_dialog/readme/CONTRIBUTORS.rst +++ b/web_widget_domain_editor_dialog/readme/CONTRIBUTORS.rst @@ -1,6 +1,7 @@ * `Tecnativa `_ - * David Vidal - * Jairo Llopis + * David Vidal + * Jairo Llopis + * Carlos Roca * Darshan Patel diff --git a/web_widget_domain_editor_dialog/static/description/index.html b/web_widget_domain_editor_dialog/static/description/index.html index 6279edf67..0bf02c99a 100644 --- a/web_widget_domain_editor_dialog/static/description/index.html +++ b/web_widget_domain_editor_dialog/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

Since v11 introduced the new domain editor widget it’s not possible to edit the selected records from the current domain.

This module reintroduces that dialog to complement the current widget with the @@ -408,7 +408,7 @@ records and those unfolded groups will be set as filters to.

You can still edit the filter with Odoo’s widget after that.

-https://raw.githubusercontent.com/OCA/web/12.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png +https://raw.githubusercontent.com/OCA/web/13.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png
@@ -416,7 +416,7 @@ records and those unfolded groups will be set as filters to.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -431,8 +431,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Contributors

diff --git a/web_widget_domain_editor_dialog/static/src/js/basic_fields.js b/web_widget_domain_editor_dialog/static/src/js/basic_fields.js index 5cd970a73..a6c67646f 100644 --- a/web_widget_domain_editor_dialog/static/src/js/basic_fields.js +++ b/web_widget_domain_editor_dialog/static/src/js/basic_fields.js @@ -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, diff --git a/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js b/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js index 586156d91..223fdb526 100644 --- a/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js +++ b/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js @@ -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")