diff --git a/setup/web_select_all_companies/odoo/addons/web_select_all_companies b/setup/web_select_all_companies/odoo/addons/web_select_all_companies new file mode 120000 index 000000000000..012ec121cc9e --- /dev/null +++ b/setup/web_select_all_companies/odoo/addons/web_select_all_companies @@ -0,0 +1 @@ +../../../../web_select_all_companies \ No newline at end of file diff --git a/setup/web_select_all_companies/setup.py b/setup/web_select_all_companies/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/web_select_all_companies/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_select_all_companies/README.rst b/web_select_all_companies/README.rst new file mode 100644 index 000000000000..0765eff92682 --- /dev/null +++ b/web_select_all_companies/README.rst @@ -0,0 +1,78 @@ +======================== +Web Select All Companies +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b2dd44d037d4c1129717952faf30f486f1ce3387df2f7a839ebed82e58bb1197 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/14.0/web_select_all_companies + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_select_all_companies + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to select or deselect all the companies in a single click. + +.. image:: https://raw.githubusercontent.com/OCA/web/14.0/web_select_all_companies/static/description/select_all_companies.png + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Telmo Santos + +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_select_all_companies/__init__.py b/web_select_all_companies/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/web_select_all_companies/__manifest__.py b/web_select_all_companies/__manifest__.py new file mode 100644 index 000000000000..a44c3132e379 --- /dev/null +++ b/web_select_all_companies/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2023 Camptocamp SA - Telmo Santos +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Web Select All Companies", + "summary": "Allows you to select all companies in one click.", + "version": "14.0.1.0.0", + "category": "Web", + "website": "https://github.com/OCA/web", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "LGPL-3", + "depends": ["web"], + "qweb": ["static/src/xml/switch_all_company_menu.xml"], + "data": ["views/web_select_all_companies.xml"], + "installable": True, +} diff --git a/web_select_all_companies/i18n/fr.po b/web_select_all_companies/i18n/fr.po new file mode 100644 index 000000000000..f5343a26a330 --- /dev/null +++ b/web_select_all_companies/i18n/fr.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_select_all_companies +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-06-16 06:01+0000\n" +"PO-Revision-Date: 2023-06-16 06:01+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_select_all_companies +#. openerp-web +#: code:addons/web_select_all_companies/static/src/xml/switch_all_company_menu.xml:0 +#, python-format +msgid "All Companies" +msgstr "Toutes Sociétés" + +#. module: web_select_all_companies +#. openerp-web +#: code:addons/web_select_all_companies/static/src/xml/switch_all_company_menu.xml:0 +#, python-format +msgid "Select All Companies" +msgstr "Sélectionnez toutes les sociétés" diff --git a/web_select_all_companies/i18n/web_select_all_companies.pot b/web_select_all_companies/i18n/web_select_all_companies.pot new file mode 100644 index 000000000000..cd0ea4e00071 --- /dev/null +++ b/web_select_all_companies/i18n/web_select_all_companies.pot @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_select_all_companies +# +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_select_all_companies +#. openerp-web +#: code:addons/web_select_all_companies/static/src/xml/switch_all_company_menu.xml:0 +#, python-format +msgid "All Companies" +msgstr "" + +#. module: web_select_all_companies +#. openerp-web +#: code:addons/web_select_all_companies/static/src/xml/switch_all_company_menu.xml:0 +#, python-format +msgid "Select All Companies" +msgstr "" diff --git a/web_select_all_companies/readme/CONTRIBUTORS.rst b/web_select_all_companies/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..8ed3aebaca05 --- /dev/null +++ b/web_select_all_companies/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Telmo Santos diff --git a/web_select_all_companies/readme/DESCRIPTION.rst b/web_select_all_companies/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..dfdb1b993a20 --- /dev/null +++ b/web_select_all_companies/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module allows you to select or deselect all the companies in a single click. + +.. image:: ./static/description/select_all_companies.png diff --git a/web_select_all_companies/static/description/icon.png b/web_select_all_companies/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/web_select_all_companies/static/description/icon.png differ diff --git a/web_select_all_companies/static/description/index.html b/web_select_all_companies/static/description/index.html new file mode 100644 index 000000000000..c99a0c885215 --- /dev/null +++ b/web_select_all_companies/static/description/index.html @@ -0,0 +1,425 @@ + + + + + + +Web Select All Companies + + + +
+

Web Select All Companies

+ + +

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

+

This module allows you to select or deselect all the companies in a single click.

+https://raw.githubusercontent.com/OCA/web/14.0/web_select_all_companies/static/description/select_all_companies.png +

Table of contents

+ +
+

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

+
    +
  • Camptocamp
  • +
+
+ +
+

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_select_all_companies/static/description/select_all_companies.gif b/web_select_all_companies/static/description/select_all_companies.gif new file mode 100644 index 000000000000..e9c3b35af229 Binary files /dev/null and b/web_select_all_companies/static/description/select_all_companies.gif differ diff --git a/web_select_all_companies/static/src/js/switch_all_company_menu.js b/web_select_all_companies/static/src/js/switch_all_company_menu.js new file mode 100644 index 000000000000..2eaadf646536 --- /dev/null +++ b/web_select_all_companies/static/src/js/switch_all_company_menu.js @@ -0,0 +1,89 @@ +/* Copyright 2023 Camptocamp - Telmo Santos + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +odoo.define( + "web_select_all_companies/static/src/js/switch_all_company_menu.js", + function (require) { + "use strict"; + + var session = require("web.session"); + var SwitchCompanyMenu = require("web.SwitchCompanyMenu"); + + SwitchCompanyMenu.include({ + init() { + this._super.apply(this, arguments); + this.allCompanyIds = session.user_companies.allowed_companies.map( + (x) => x[0] + ); + // Get allowed companies from user context and compare with all companies to check if all companies are selected or not + // and set flag accordingly + this.allowed_company_ids = session.user_context.allowed_company_ids; + this.isAllCompaniesSelected = + this.allowed_company_ids.length == this.allCompanyIds.length; + }, + + /** + * @private + * @param {MouseEvent|KeyEvent} ev + */ + _onToggleCompanyClick: function (ev) { + if ( + ev.type == "keydown" && + ev.which != $.ui.keyCode.ENTER && + ev.which != $.ui.keyCode.SPACE + ) { + return; + } + ev.preventDefault(); + ev.stopPropagation(); + var dropdownItem = $(ev.currentTarget).parent(); + var companyID = dropdownItem.data("company-id"); + var dropdownMenu = dropdownItem.parent(); + var all_items = dropdownMenu.children(); + var toggle_company_div = all_items[0].children[0]; + var toggle_company_i = toggle_company_div.children[0].children[0]; + if (!companyID) { + // Calculate length - 1 because one element is the 'toggle all companies' item + this.isAllCompaniesSelected = + dropdownMenu.find(".fa-check-square").length - 1 == + this.allCompanyIds.length; + // Deselect all companies by toggling class on html elements and setting company data in session + if (this.isAllCompaniesSelected) { + all_items + .find(".fa-check-square") + .removeClass("fa-check-square") + .addClass("fa-square-o"); + toggle_company_i.classList.replace( + "fa-check-square", + "fa-square-o" + ); + $(ev.currentTarget).attr("aria-checked", "false"); + session.setCompanies(this.allowed_company_ids[0], []); + session.user_context.allowed_company_ids = []; + } else { + // Select all companies by toggling class on html elements and setting company data in session + var allowed_company_ids = this.allowed_company_ids; + var current_company_id = allowed_company_ids[0]; + _.each(this.allCompanyIds, (company_id) => { + if (!allowed_company_ids.includes(company_id)) { + allowed_company_ids.push(company_id); + } + }); + all_items + .find(".fa-check-square") + .removeClass("fa-square-o") + .addClass("fa-check-square"); + toggle_company_i.classList.replace( + "fa-square-o", + "fa-check-square" + ); + $(ev.currentTarget).attr("aria-checked", "true"); + session.setCompanies(current_company_id, allowed_company_ids); + } + } else { + return this._super.apply(this, arguments); + } + }, + }); + } +); diff --git a/web_select_all_companies/static/src/scss/switch_all_company_menu.scss b/web_select_all_companies/static/src/scss/switch_all_company_menu.scss new file mode 100644 index 000000000000..bf6cb0fcced7 --- /dev/null +++ b/web_select_all_companies/static/src/scss/switch_all_company_menu.scss @@ -0,0 +1,4 @@ +.all-companies-item { + font-size: 16px; + font-weight: bold; +} diff --git a/web_select_all_companies/static/src/xml/switch_all_company_menu.xml b/web_select_all_companies/static/src/xml/switch_all_company_menu.xml new file mode 100644 index 000000000000..76c30b56138e --- /dev/null +++ b/web_select_all_companies/static/src/xml/switch_all_company_menu.xml @@ -0,0 +1,39 @@ + + + + + + + + diff --git a/web_select_all_companies/views/web_select_all_companies.xml b/web_select_all_companies/views/web_select_all_companies.xml new file mode 100644 index 000000000000..669764ac8a6c --- /dev/null +++ b/web_select_all_companies/views/web_select_all_companies.xml @@ -0,0 +1,15 @@ + + +