diff --git a/setup/web_widget_domain_editor_dialog/odoo/addons/web_widget_domain_editor_dialog b/setup/web_widget_domain_editor_dialog/odoo/addons/web_widget_domain_editor_dialog new file mode 120000 index 000000000..a36691af2 --- /dev/null +++ b/setup/web_widget_domain_editor_dialog/odoo/addons/web_widget_domain_editor_dialog @@ -0,0 +1 @@ +../../../../web_widget_domain_editor_dialog \ No newline at end of file diff --git a/setup/web_widget_domain_editor_dialog/setup.py b/setup/web_widget_domain_editor_dialog/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_widget_domain_editor_dialog/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_widget_domain_editor_dialog/README.rst b/web_widget_domain_editor_dialog/README.rst new file mode 100644 index 000000000..e4730794b --- /dev/null +++ b/web_widget_domain_editor_dialog/README.rst @@ -0,0 +1,113 @@ +=============================== +Web Widget Domain Editor Dialog +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:556e58fec03e10a766775e9fcf51a71af99cd84efaa2ee47cd937bee7ef9312f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.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-16-0/web-16-0-web_widget_domain_editor_dialog + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 + :alt: Try me on Runboat + +|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/16.0/web_widget_domain_editor_dialog/static/src/img/behaviour.gif + :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 to smash 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 + * Carlos Roca + +* Darshan Patel +* Helly kapatel +* Carlos Lopez + +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 000000000..e69de29bb diff --git a/web_widget_domain_editor_dialog/__manifest__.py b/web_widget_domain_editor_dialog/__manifest__.py new file mode 100644 index 000000000..7dfdd8a4c --- /dev/null +++ b/web_widget_domain_editor_dialog/__manifest__.py @@ -0,0 +1,18 @@ +# 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": "16.0.1.0.0", + "category": "Web", + "author": "Tecnativa," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", + "license": "AGPL-3", + "depends": ["web"], + "assets": { + "web.assets_backend": [ + "/web_widget_domain_editor_dialog/static/src/js/*.esm.js", + ], + }, + "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 000000000..ca9cfd0de --- /dev/null +++ b/web_widget_domain_editor_dialog/i18n/es.po @@ -0,0 +1,34 @@ +# 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" +"Language: \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/basic_fields.js:0 +#, 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:0 +#, python-format +msgid "Selected domain" +msgstr "Dominio seleccionado" + +#~ msgid "Custom Filter" +#~ msgstr "Filtro personalizado" 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 000000000..859e49f6b --- /dev/null +++ b/web_widget_domain_editor_dialog/i18n/web_widget_domain_editor_dialog.pot @@ -0,0 +1,28 @@ +# 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 15.0\n" +"Report-Msgid-Bugs-To: \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/basic_fields.js:0 +#, 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:0 +#, python-format +msgid "Selected domain" +msgstr "" diff --git a/web_widget_domain_editor_dialog/i18n/zh_CN.po b/web_widget_domain_editor_dialog/i18n/zh_CN.po new file mode 100644 index 000000000..5567f2767 --- /dev/null +++ b/web_widget_domain_editor_dialog/i18n/zh_CN.po @@ -0,0 +1,34 @@ +# 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 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-09-01 17:23+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\n" + +#. module: web_widget_domain_editor_dialog +#. openerp-web +#: code:addons/web_widget_domain_editor_dialog/static/src/js/basic_fields.js:0 +#, 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:0 +#, python-format +msgid "Selected domain" +msgstr "选定的域" + +#~ msgid "Custom Filter" +#~ 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 000000000..274c293d4 --- /dev/null +++ b/web_widget_domain_editor_dialog/readme/CONTRIBUTORS.rst @@ -0,0 +1,9 @@ +* `Tecnativa `_ + + * David Vidal + * Jairo Llopis + * Carlos Roca + +* Darshan Patel +* Helly kapatel +* Carlos Lopez 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 000000000..4e92c10e7 --- /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 000000000..d3a918fcb --- /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.gif + :align: center + :width: 600 px diff --git a/web_widget_domain_editor_dialog/static/description/icon.png b/web_widget_domain_editor_dialog/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_widget_domain_editor_dialog/static/description/icon.png differ 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 000000000..8405baf43 --- /dev/null +++ b/web_widget_domain_editor_dialog/static/description/index.html @@ -0,0 +1,459 @@ + + + + + + +Web Widget Domain Editor Dialog + + + +
+

Web Widget Domain Editor Dialog

+ + +

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

+

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/16.0/web_widget_domain_editor_dialog/static/src/img/behaviour.gif +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

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 000000000..47f4c17eb 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/domain_field.esm.js b/web_widget_domain_editor_dialog/static/src/js/domain_field.esm.js new file mode 100644 index 000000000..4d7544977 --- /dev/null +++ b/web_widget_domain_editor_dialog/static/src/js/domain_field.esm.js @@ -0,0 +1,39 @@ +/** @odoo-module **/ +/* Copyright 2019 Tecnativa - David Vidal + * Copyright 2024 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ +import {DomainField} from "@web/views/fields/domain/domain_field"; +import {DomainEditorDialog} from "./widget_domain_editor_dialog.esm"; +import {patch} from "@web/core/utils/patch"; + +patch(DomainField.prototype, "web_widget_domain_editor_dialog.DomainField", { + onButtonClick(ev) { + ev.preventDefault(); + const self = this; + if (this.props.readonly) { + return this._super.apply(this, arguments); + } + if (!this.props.value) { + this.props.value = "[]"; + } + this.addDialog(DomainEditorDialog, { + title: this.env._t("Select records..."), + noCreate: true, + multiSelect: true, + resModel: this.getResModel(this.props), + dynamicFilters: [ + { + description: this.env._t("Selected domain"), + domain: + this.getDomain(this.props.value).toList( + this.getContext(this.props) + ) || [], + }, + ], + context: this.getContext(this.props) || {}, + onSelected: function (resIds) { + self.update(this.get_domain(resIds)); + }, + }); + }, +}); diff --git a/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.esm.js b/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.esm.js new file mode 100644 index 000000000..ab004de16 --- /dev/null +++ b/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.esm.js @@ -0,0 +1,81 @@ +/** @odoo-module **/ +/* Copyright 2019 Tecnativa - David Vidal + * Copyright 2024 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ +import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog"; +import {Domain} from "@web/core/domain"; + +export function findChildren(comp, predicate = (e) => e) { + const queue = []; + [].unshift.apply(queue, Object.values(comp.__owl__.children)); + + while (queue.length > 0) { + const curNode = queue.pop(); + if (predicate(curNode)) { + return curNode; + } + [].unshift.apply(queue, Object.values(curNode.component.__owl__.children)); + } +} + +export class DomainEditorDialog extends SelectCreateDialog { + /** + * Bind this to allow call get_domain from onSelected function definition. + * + * @override + */ + async select(resIds) { + if (this.props.onSelected) { + const onselected = this.props.onSelected.bind(this); + await onselected(resIds); + this.props.close(); + } + } + + _getDomainOfGroups(groups, domain) { + const groups_unfolded = _.filter(groups, (g) => !g.isFolded); + var groups_domain = []; + for (var group of groups_unfolded) { + var group_list = group.list; + if (group_list.groupBy.length) { + groups_domain.push(this._getDomainOfGroups(group_list.groups, domain)); + } else { + var group_domain = group_list.domain; + _.each(domain, (d) => { + group_domain = _.without( + group_domain, + _.filter(group_domain, (x) => { + return _.isEqual(x, d); + })[0] + ); + }); + group_domain = _.without(group_domain, "&"); + groups_domain.push(group_domain); + } + } + return Domain.or(groups_domain).toList(); + } + + get_domain(resIds) { + const dynamicList = findChildren( + this, + (node) => + node.component && + node.component.model && + node.component.model.root && + ["DynamicGroupList", "DynamicRecordList"].includes( + node.component.model.root.constructor.name + ) + ).component.model.root; + let domain = dynamicList.domain; + let group_domain = []; + if ($(".o_list_record_selector input").prop("checked")) { + if (dynamicList.groupBy.length) { + group_domain = this._getDomainOfGroups(dynamicList.groups, domain); + } + } else { + domain = domain.concat([["id", "in", resIds]]); + } + return JSON.stringify(domain.concat(group_domain)); + } +}