-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] web_select_all_companies: Backporting from 15.0 to 14.0
- Loading branch information
1 parent
a29b090
commit f9d48ea
Showing
9 changed files
with
159 additions
and
96 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/web_select_all_companies/odoo/addons/web_select_all_companies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../web_select_all_companies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
|
@@ -8,10 +9,11 @@ | |
|
||
/* | ||
:Author: David Goodger ([email protected]) | ||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ | ||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ | ||
:Copyright: This stylesheet has been placed in the public domain. | ||
|
||
Default cascading style sheet for the HTML output of Docutils. | ||
Despite the name, some widely supported CSS2 features are used. | ||
|
||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to | ||
customize this style sheet. | ||
|
@@ -274,7 +276,7 @@ | |
margin-left: 2em ; | ||
margin-right: 2em } | ||
|
||
pre.code .ln { color: grey; } /* line numbers */ | ||
pre.code .ln { color: gray; } /* line numbers */ | ||
pre.code, code { background-color: #eeeeee } | ||
pre.code .comment, code .comment { color: #5C6576 } | ||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } | ||
|
@@ -300,7 +302,7 @@ | |
span.pre { | ||
white-space: pre } | ||
|
||
span.problematic { | ||
span.problematic, pre.problematic { | ||
color: red } | ||
|
||
span.section-subtitle { | ||
|
@@ -368,9 +370,9 @@ <h1 class="title">Web Select All Companies</h1> | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:b2dd44d037d4c1129717952faf30f486f1ce3387df2f7a839ebed82e58bb1197 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> | ||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/15.0/web_select_all_companies"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_select_all_companies"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> | ||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/14.0/web_select_all_companies"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_select_all_companies"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> | ||
<p>This module allows you to select or deselect all the companies in a single click.</p> | ||
<img alt="https://raw.githubusercontent.com/OCA/web/15.0/web_select_all_companies/static/description/select_all_companies.png" src="https://raw.githubusercontent.com/OCA/web/15.0/web_select_all_companies/static/description/select_all_companies.png" /> | ||
<img alt="https://raw.githubusercontent.com/OCA/web/14.0/web_select_all_companies/static/description/select_all_companies.png" src="https://raw.githubusercontent.com/OCA/web/14.0/web_select_all_companies/static/description/select_all_companies.png" /> | ||
<p><strong>Table of contents</strong></p> | ||
<div class="contents local topic" id="contents"> | ||
<ul class="simple"> | ||
|
@@ -388,7 +390,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1> | |
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>. | ||
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 | ||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_select_all_companies%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> | ||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_select_all_companies%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> | ||
<p>Do not contact contributors directly about support or help with technical issues.</p> | ||
</div> | ||
<div class="section" id="credits"> | ||
|
@@ -408,11 +410,13 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2> | |
<div class="section" id="maintainers"> | ||
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2> | ||
<p>This module is maintained by the OCA.</p> | ||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> | ||
<a class="reference external image-reference" href="https://odoo-community.org"> | ||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /> | ||
</a> | ||
<p>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.</p> | ||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_select_all_companies">OCA/web</a> project on GitHub.</p> | ||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/14.0/web_select_all_companies">OCA/web</a> project on GitHub.</p> | ||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> | ||
</div> | ||
</div> | ||
|
45 changes: 0 additions & 45 deletions
45
web_select_all_companies/static/src/js/switch_all_company_menu.esm.js
This file was deleted.
Oops, something went wrong.
89 changes: 89 additions & 0 deletions
89
web_select_all_companies/static/src/js/switch_all_company_menu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
}, | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
web_select_all_companies/views/web_select_all_companies.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<template | ||
id="assets_backend" | ||
name="web_select_all_companies assets" | ||
inherit_id="web.assets_backend" | ||
> | ||
<xpath expr="." position="inside"> | ||
<script | ||
type="text/javascript" | ||
src="/web_select_all_companies/static/src/js/switch_all_company_menu.js" | ||
/> | ||
</xpath> | ||
</template> | ||
</odoo> |