diff --git a/web_widget_domain_editor_dialog/README.rst b/web_widget_domain_editor_dialog/README.rst new file mode 100644 index 00000000..a9d6f875 --- /dev/null +++ b/web_widget_domain_editor_dialog/README.rst @@ -0,0 +1,105 @@ +=============================== +Web Widget Domain Editor Dialog +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/11.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-11-0/web-11-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/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +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 +powerful search engine of Odoo. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +In any view with a domain field widget and model, but we'll make the example +with a user filter: + +#. Enter debug mode. +#. Go to the *Debug menu* and select the option *Manage Filters* +#. Create a new one +#. Put a name to the filter and select a model (e.g.: Contact) +#. Click on the record selection button and a list dialog opens. There you can + either: + + * Select individual records: those ids will be added to the domain. + * Set filters that will be applied to the domain and select all the records + to add it as a new filter. + * Set groups that will be converted into search filters, select all the + records and those unfolded groups will be set as filters to. + +You can still edit the filter with Odoo's widget after that. + +.. figure:: https://raw.githubusercontent.com/OCA/web/11.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png + :align: center + :width: 600 px + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_ + + * David Vidal + * Jairo Llopis + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_domain_editor_dialog/__init__.py b/web_widget_domain_editor_dialog/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/web_widget_domain_editor_dialog/__manifest__.py b/web_widget_domain_editor_dialog/__manifest__.py new file mode 100644 index 00000000..9850cdc0 --- /dev/null +++ b/web_widget_domain_editor_dialog/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Web Widget Domain Editor Dialog', + 'summary': 'Recovers the Domain Editor Dialog functionality', + 'version': '11.0.1.0.0', + 'category': 'Web', + 'author': 'Tecnativa,' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/web', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + 'data': [ + 'views/templates.xml', + ], + 'application': False, + 'installable': True, +} diff --git a/web_widget_domain_editor_dialog/i18n/es.po b/web_widget_domain_editor_dialog/i18n/es.po new file mode 100644 index 00000000..12502f9d --- /dev/null +++ b/web_widget_domain_editor_dialog/i18n/es.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_widget_domain_editor_dialog +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-02-22 11:23+0000\n" +"PO-Revision-Date: 2019-02-22 11:23+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_widget_domain_editor_dialog +#. openerp-web +#: code:addons/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js:18 +#, python-format +msgid "Custom Filter" +msgstr "Filtro personalizado" + +#. module: web_widget_domain_editor_dialog +#. openerp-web +#: code:addons/web_widget_domain_editor_dialog/static/src/js/basic_fields.js:21 +#, python-format +msgid "Select records..." +msgstr "Seleccionar registros..." + +#. module: web_widget_domain_editor_dialog +#. openerp-web +#: code:addons/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js:31 +#, python-format +msgid "Selected domain" +msgstr "Dominio seleccionado" diff --git a/web_widget_domain_editor_dialog/i18n/web_widget_domain_editor_dialog.pot b/web_widget_domain_editor_dialog/i18n/web_widget_domain_editor_dialog.pot new file mode 100644 index 00000000..4f4973f4 --- /dev/null +++ b/web_widget_domain_editor_dialog/i18n/web_widget_domain_editor_dialog.pot @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_widget_domain_editor_dialog +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-02-22 11:22+0000\n" +"PO-Revision-Date: 2019-02-22 11:22+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_widget_domain_editor_dialog +#. openerp-web +#: code:addons/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js:18 +#, python-format +msgid "Custom Filter" +msgstr "" + +#. module: web_widget_domain_editor_dialog +#. openerp-web +#: code:addons/web_widget_domain_editor_dialog/static/src/js/basic_fields.js:21 +#, python-format +msgid "Select records..." +msgstr "" + +#. module: web_widget_domain_editor_dialog +#. openerp-web +#: code:addons/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js:31 +#, python-format +msgid "Selected domain" +msgstr "" + diff --git a/web_widget_domain_editor_dialog/readme/CONTRIBUTORS.rst b/web_widget_domain_editor_dialog/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..c3b446a6 --- /dev/null +++ b/web_widget_domain_editor_dialog/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_ + + * David Vidal + * Jairo Llopis diff --git a/web_widget_domain_editor_dialog/readme/DESCRIPTION.rst b/web_widget_domain_editor_dialog/readme/DESCRIPTION.rst new file mode 100644 index 00000000..4e92c10e --- /dev/null +++ b/web_widget_domain_editor_dialog/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +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 +powerful search engine of Odoo. diff --git a/web_widget_domain_editor_dialog/readme/USAGE.rst b/web_widget_domain_editor_dialog/readme/USAGE.rst new file mode 100644 index 00000000..6d71caea --- /dev/null +++ b/web_widget_domain_editor_dialog/readme/USAGE.rst @@ -0,0 +1,21 @@ +In any view with a domain field widget and model, but we'll make the example +with a user filter: + +#. Enter debug mode. +#. Go to the *Debug menu* and select the option *Manage Filters* +#. Create a new one +#. Put a name to the filter and select a model (e.g.: Contact) +#. Click on the record selection button and a list dialog opens. There you can + either: + + * Select individual records: those ids will be added to the domain. + * Set filters that will be applied to the domain and select all the records + to add it as a new filter. + * Set groups that will be converted into search filters, select all the + records and those unfolded groups will be set as filters to. + +You can still edit the filter with Odoo's widget after that. + +.. figure:: ../static/src/img/behaviour.png + :align: center + :width: 600 px diff --git a/web_widget_domain_editor_dialog/static/description/index.html b/web_widget_domain_editor_dialog/static/description/index.html new file mode 100644 index 00000000..4b5a1863 --- /dev/null +++ b/web_widget_domain_editor_dialog/static/description/index.html @@ -0,0 +1,453 @@ + + + + + + +Web Widget Domain Editor Dialog + + + +
+

Web Widget Domain Editor Dialog

+ + +

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 +powerful search engine of Odoo.

+

Table of contents

+ +
+

Usage

+

In any view with a domain field widget and model, but we’ll make the example +with a user filter:

+
    +
  1. Enter debug mode.
  2. +
  3. Go to the Debug menu and select the option Manage Filters
  4. +
  5. Create a new one
  6. +
  7. Put a name to the filter and select a model (e.g.: Contact)
  8. +
  9. Click on the record selection button and a list dialog opens. There you can +either:
  10. +
+
+
    +
  • Select individual records: those ids will be added to the domain.
  • +
  • Set filters that will be applied to the domain and select all the records +to add it as a new filter.
  • +
  • Set groups that will be converted into search filters, select all the +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/11.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png +
+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_widget_domain_editor_dialog/static/src/img/behaviour.gif b/web_widget_domain_editor_dialog/static/src/img/behaviour.gif new file mode 100644 index 00000000..47f4c17e Binary files /dev/null and b/web_widget_domain_editor_dialog/static/src/img/behaviour.gif differ 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 new file mode 100644 index 00000000..341d8b2e --- /dev/null +++ b/web_widget_domain_editor_dialog/static/src/js/basic_fields.js @@ -0,0 +1,41 @@ +/* Copyright 2019 Tecnativa - David Vidal +* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +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; + + basic_fields.FieldDomain.include({ + _onShowSelectionButtonClick: function (event) { + event.preventDefault(); + var _this = this; + if (this.mode === 'readonly') { + return this._super.apply(this, arguments); + } + var dialog = new DomainEditorDialog(this, { + title: _t('Select records...'), + res_model: this._domainModel, + default_domain: this.value, + readonly: false, + disable_multiple_selection: false, + no_create: true, + on_selected: function (selected_ids) { + _this.domainSelector + .setDomain(this.get_domain(selected_ids)) + .then(_this._replaceContent.bind(_this)); + _this.trigger_up( + 'domain_changed', + {child: _this, alreadyRedrawn: true}); + }, + }).open(); + this.trigger("dialog_opened", dialog); + return dialog; + }, + + }); +}); 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 new file mode 100644 index 00000000..7e07505c --- /dev/null +++ b/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js @@ -0,0 +1,96 @@ +/* Copyright 2019 Tecnativa - David Vidal + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +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; + + var DomainEditorDialog = view_dialogs.SelectCreateDialog.extend({ + init: function () { + this._super.apply(this, arguments); + var _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; + }, + }, + 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; + if (this.$('.o_list_record_selector input').prop('checked')) { + if (search_data.groupedBy.length) { + group_domain = _.filter( + search_data.data, function (x) { + return x.res_ids.length; + }) + .map(function (x) { + return x.domain; + }); + group_domain = _.flatten(group_domain, true); + // Compute domain difference + _.each(domain, function (d) { + group_domain = _.without( + group_domain, _.filter(group_domain, function (x) { + return _.isEqual(x, d); + })[0]); + }); + // Strip operators to leave just the group domains + group_domain = _.without(group_domain, "&"); + // Add OR operators if there is more than one group + group_domain = _.times( + group_domain.length - 1, + _.constant('|')).concat(group_domain); + } + } else { + var ids = selected_ids.map(function (x) { + return x.id; + }); + domain = domain.concat([["id", "in", ids]]); + } + return domain.concat(group_domain); + }, + + on_view_list_loaded: function () { + this.$('.o_list_record_selector input').prop('checked', true); + this.$footer.find(".o_selectcreatepopup_search_select") + .prop('disabled', false); + }, + }); + + return DomainEditorDialog; + +}); diff --git a/web_widget_domain_editor_dialog/views/templates.xml b/web_widget_domain_editor_dialog/views/templates.xml new file mode 100644 index 00000000..3277b018 --- /dev/null +++ b/web_widget_domain_editor_dialog/views/templates.xml @@ -0,0 +1,11 @@ + + + +