From 32b84f2079e99085bb30351fa68a1bce11cb44f6 Mon Sep 17 00:00:00 2001
From: Daryl Chen
Date: Thu, 14 Mar 2024 13:34:57 -0400
Subject: [PATCH] [IMP] web_favicon: pre-commit auto fixes
---
web_favicon/README.rst | 58 +++++-----
web_favicon/__manifest__.py | 4 +-
web_favicon/controllers/web_favicon.py | 19 ++--
web_favicon/models/res_company.py | 15 +--
web_favicon/pyproject.toml | 3 +
web_favicon/readme/CONFIGURE.md | 16 +++
web_favicon/readme/CONFIGURE.rst | 15 ---
web_favicon/readme/DESCRIPTION.md | 9 ++
web_favicon/readme/DESCRIPTION.rst | 10 --
web_favicon/readme/ROADMAP.md | 8 ++
web_favicon/readme/ROADMAP.rst | 6 --
web_favicon/static/description/index.html | 49 +++++----
web_favicon/static/src/img/browserconfig.xml | 10 +-
web_favicon/static/src/img/manifest.json | 78 +++++++-------
.../src/img/website_favicon_sample.html | 102 ++++++++++++++----
web_favicon/tests/test_web_favicon.py | 38 ++++---
web_favicon/views/res_company.xml | 7 +-
web_favicon/views/templates.xml | 4 +-
18 files changed, 266 insertions(+), 185 deletions(-)
create mode 100644 web_favicon/pyproject.toml
create mode 100644 web_favicon/readme/CONFIGURE.md
delete mode 100644 web_favicon/readme/CONFIGURE.rst
create mode 100644 web_favicon/readme/DESCRIPTION.md
delete mode 100644 web_favicon/readme/DESCRIPTION.rst
create mode 100644 web_favicon/readme/ROADMAP.md
delete mode 100644 web_favicon/readme/ROADMAP.rst
diff --git a/web_favicon/README.rst b/web_favicon/README.rst
index da213d393..8e5e28a73 100644
--- a/web_favicon/README.rst
+++ b/web_favicon/README.rst
@@ -17,22 +17,21 @@ Custom shortcut icon
: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_favicon
+ :target: https://github.com/OCA/web/tree/17.0/web_favicon
: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_favicon
+ :target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_favicon
: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=12.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
-
-This module was written to allow you to customize your Odoo instance's shortcut
-icon (aka favicon). This is useful for branding purposes, but also for
-integrators who have many different Odoo instances running and need to see at a
-glance which browser tab does what.
+This module was written to allow you to customize your Odoo instance's
+shortcut icon (aka favicon). This is useful for branding purposes, but
+also for integrators who have many different Odoo instances running and
+need to see at a glance which browser tab does what.
The icon is shown also for portal users when the website modules are not
installed.
@@ -48,30 +47,33 @@ Configuration
=============
Upload your favicon (16x16, 32x32, 64x64 or "as big as possible") on the
-company form. The file format would be ico, gif or png with 16x16, 32x32 or
-64x64 pixels and 16 colors. Highers resolutions or colors support depends on
-the used browser, but most modern browsers do.
+company form. The file format would be ico, gif or png with 16x16, 32x32
+or 64x64 pixels and 16 colors. Highers resolutions or colors support
+depends on the used browser, but most modern browsers do.
-Note that most browsers cache favicons basically forever, so if you want your
-icon to show up, you'll most probably have to delete you browser cache.
-Some browsers can refresh the favicon, accessing the URL
+Note that most browsers cache favicons basically forever, so if you want
+your icon to show up, you'll most probably have to delete you browser
+cache. Some browsers can refresh the favicon, accessing the URL
/web_favicon/favicon.
-You have a sample SVG that can be used as template for generating your icon
-in /static/src/img/master_original_favicon.svg. You can also search for some
-favicon generators across the web.
+You have a sample SVG that can be used as template for generating your
+icon in /static/src/img/master_original_favicon.svg. You can also search
+for some favicon generators across the web.
-To allow a user to edit the favicon it has to be member of group "Administration / Settings".
+To allow a user to edit the favicon it has to be member of group
+"Administration / Settings".
Known issues / Roadmap
======================
-* Allow to upload some big icon (preferrably SVG or the like) and generate
- all the icons from it
-* Generate icons suitable for mobile devices and web apps (see /static/src/img/
- folder inside the module for a sample of the possible current formats.
-* Put the icon definition at system level, not at company level. It doesn't
- make sense (as the icon is cached) to have a different icon per company.
+- Allow to upload some big icon (preferrably SVG or the like) and
+ generate all the icons from it
+- Generate icons suitable for mobile devices and web apps (see
+ /static/src/img/ folder inside the module for a sample of the
+ possible current formats.
+- Put the icon definition at system level, not at company level. It
+ doesn't make sense (as the icon is cached) to have a different icon
+ per company.
Bug Tracker
===========
@@ -79,7 +81,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 to smash it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -87,13 +89,13 @@ Credits
=======
Authors
-~~~~~~~
+-------
* Therp BV
* Tecnativa
Maintainers
-~~~~~~~~~~~
+-----------
This module is maintained by the OCA.
@@ -105,6 +107,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_favicon/__manifest__.py b/web_favicon/__manifest__.py
index 421c7b9ff..ef1e90eb9 100644
--- a/web_favicon/__manifest__.py
+++ b/web_favicon/__manifest__.py
@@ -5,9 +5,7 @@
{
"name": "Custom shortcut icon",
"version": "12.0.1.0.0",
- "author": "Therp BV, "
- "Tecnativa, "
- "Odoo Community Association (OCA)",
+ "author": "Therp BV, " "Tecnativa, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Website",
"summary": "Allows to set a custom shortcut icon (aka favicon)",
diff --git a/web_favicon/controllers/web_favicon.py b/web_favicon/controllers/web_favicon.py
index 5e135a1b1..a3d594630 100644
--- a/web_favicon/controllers/web_favicon.py
+++ b/web_favicon/controllers/web_favicon.py
@@ -2,28 +2,29 @@
# Copyright 2017 QubiQ 2010
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from io import BytesIO
import base64
+from io import BytesIO
+
from odoo import http
from odoo.tools.misc import file_open
class WebFavicon(http.Controller):
-
- @http.route('/web_favicon/favicon', type='http', auth="none")
+ @http.route("/web_favicon/favicon", type="http", auth="none")
def icon(self):
request = http.request
- if 'uid' in request.env.context:
- user = request.env['res.users'].browse(request.env.context['uid'])
+ if "uid" in request.env.context:
+ user = request.env["res.users"].browse(request.env.context["uid"])
company = user.sudo(user.id).company_id
else:
- company = request.env['res.company'].search([], limit=1)
+ company = request.env["res.company"].search([], limit=1)
favicon = company.favicon_backend
favicon_mimetype = company.favicon_backend_mimetype
if not favicon:
- favicon = file_open('web/static/src/img/favicon.ico', 'rb')
- favicon_mimetype = 'image/x-icon'
+ favicon = file_open("web/static/src/img/favicon.ico", "rb")
+ favicon_mimetype = "image/x-icon"
else:
favicon = BytesIO(base64.b64decode(favicon))
return request.make_response(
- favicon.read(), [('Content-Type', favicon_mimetype)])
+ favicon.read(), [("Content-Type", favicon_mimetype)]
+ )
diff --git a/web_favicon/models/res_company.py b/web_favicon/models/res_company.py
index 998948248..e101dced1 100644
--- a/web_favicon/models/res_company.py
+++ b/web_favicon/models/res_company.py
@@ -2,15 +2,18 @@
# Copyright 2016 Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import models, fields
+from odoo import fields, models
class ResCompany(models.Model):
- _inherit = 'res.company'
+ _inherit = "res.company"
favicon_backend = fields.Binary()
favicon_backend_mimetype = fields.Selection(
- selection=[('image/x-icon', 'image/x-icon'),
- ('image/gif', 'image/gif'),
- ('image/png', 'image/png')],
- help='Set the mimetype of your file.')
+ selection=[
+ ("image/x-icon", "image/x-icon"),
+ ("image/gif", "image/gif"),
+ ("image/png", "image/png"),
+ ],
+ help="Set the mimetype of your file.",
+ )
diff --git a/web_favicon/pyproject.toml b/web_favicon/pyproject.toml
new file mode 100644
index 000000000..4231d0ccc
--- /dev/null
+++ b/web_favicon/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["whool"]
+build-backend = "whool.buildapi"
diff --git a/web_favicon/readme/CONFIGURE.md b/web_favicon/readme/CONFIGURE.md
new file mode 100644
index 000000000..182d9d538
--- /dev/null
+++ b/web_favicon/readme/CONFIGURE.md
@@ -0,0 +1,16 @@
+Upload your favicon (16x16, 32x32, 64x64 or "as big as possible") on the
+company form. The file format would be ico, gif or png with 16x16, 32x32
+or 64x64 pixels and 16 colors. Highers resolutions or colors support
+depends on the used browser, but most modern browsers do.
+
+Note that most browsers cache favicons basically forever, so if you want
+your icon to show up, you'll most probably have to delete you browser
+cache. Some browsers can refresh the favicon, accessing the URL
+\/web_favicon/favicon.
+
+You have a sample SVG that can be used as template for generating your
+icon in /static/src/img/master_original_favicon.svg. You can also search
+for some favicon generators across the web.
+
+To allow a user to edit the favicon it has to be member of group
+"Administration / Settings".
diff --git a/web_favicon/readme/CONFIGURE.rst b/web_favicon/readme/CONFIGURE.rst
deleted file mode 100644
index 55777b650..000000000
--- a/web_favicon/readme/CONFIGURE.rst
+++ /dev/null
@@ -1,15 +0,0 @@
-Upload your favicon (16x16, 32x32, 64x64 or "as big as possible") on the
-company form. The file format would be ico, gif or png with 16x16, 32x32 or
-64x64 pixels and 16 colors. Highers resolutions or colors support depends on
-the used browser, but most modern browsers do.
-
-Note that most browsers cache favicons basically forever, so if you want your
-icon to show up, you'll most probably have to delete you browser cache.
-Some browsers can refresh the favicon, accessing the URL
-/web_favicon/favicon.
-
-You have a sample SVG that can be used as template for generating your icon
-in /static/src/img/master_original_favicon.svg. You can also search for some
-favicon generators across the web.
-
-To allow a user to edit the favicon it has to be member of group "Administration / Settings".
diff --git a/web_favicon/readme/DESCRIPTION.md b/web_favicon/readme/DESCRIPTION.md
new file mode 100644
index 000000000..8822c7c00
--- /dev/null
+++ b/web_favicon/readme/DESCRIPTION.md
@@ -0,0 +1,9 @@
+This module was written to allow you to customize your Odoo instance's
+shortcut icon (aka favicon). This is useful for branding purposes, but
+also for integrators who have many different Odoo instances running and
+need to see at a glance which browser tab does what.
+
+The icon is shown also for portal users when the website modules are not
+installed.
+
+More info about favicon:
diff --git a/web_favicon/readme/DESCRIPTION.rst b/web_favicon/readme/DESCRIPTION.rst
deleted file mode 100644
index 832607856..000000000
--- a/web_favicon/readme/DESCRIPTION.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-
-This module was written to allow you to customize your Odoo instance's shortcut
-icon (aka favicon). This is useful for branding purposes, but also for
-integrators who have many different Odoo instances running and need to see at a
-glance which browser tab does what.
-
-The icon is shown also for portal users when the website modules are not
-installed.
-
-More info about favicon: https://en.wikipedia.org/wiki/Favicon
diff --git a/web_favicon/readme/ROADMAP.md b/web_favicon/readme/ROADMAP.md
new file mode 100644
index 000000000..35cb8f442
--- /dev/null
+++ b/web_favicon/readme/ROADMAP.md
@@ -0,0 +1,8 @@
+- Allow to upload some big icon (preferrably SVG or the like) and
+ generate all the icons from it
+- Generate icons suitable for mobile devices and web apps (see
+ /static/src/img/ folder inside the module for a sample of the possible
+ current formats.
+- Put the icon definition at system level, not at company level. It
+ doesn't make sense (as the icon is cached) to have a different icon
+ per company.
diff --git a/web_favicon/readme/ROADMAP.rst b/web_favicon/readme/ROADMAP.rst
deleted file mode 100644
index b4d00087c..000000000
--- a/web_favicon/readme/ROADMAP.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-* Allow to upload some big icon (preferrably SVG or the like) and generate
- all the icons from it
-* Generate icons suitable for mobile devices and web apps (see /static/src/img/
- folder inside the module for a sample of the possible current formats.
-* Put the icon definition at system level, not at company level. It doesn't
- make sense (as the icon is cached) to have a different icon per company.
diff --git a/web_favicon/static/description/index.html b/web_favicon/static/description/index.html
index c7696e722..c162e1436 100644
--- a/web_favicon/static/description/index.html
+++ b/web_favicon/static/description/index.html
@@ -369,11 +369,11 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4af1c92721d131728f92364370ba5145f45bac9b8e4d4396572737b9ccacd56e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
-
This module was written to allow you to customize your Odoo instance’s shortcut
-icon (aka favicon). This is useful for branding purposes, but also for
-integrators who have many different Odoo instances running and need to see at a
-glance which browser tab does what.
+
+
This module was written to allow you to customize your Odoo instance’s
+shortcut icon (aka favicon). This is useful for branding purposes, but
+also for integrators who have many different Odoo instances running and
+need to see at a glance which browser tab does what.
The icon is shown also for portal users when the website modules are not
installed.
Upload your favicon (16x16, 32x32, 64x64 or “as big as possible”) on the
-company form. The file format would be ico, gif or png with 16x16, 32x32 or
-64x64 pixels and 16 colors. Highers resolutions or colors support depends on
-the used browser, but most modern browsers do.
-
Note that most browsers cache favicons basically forever, so if you want your
-icon to show up, you’ll most probably have to delete you browser cache.
-Some browsers can refresh the favicon, accessing the URL
+company form. The file format would be ico, gif or png with 16x16, 32x32
+or 64x64 pixels and 16 colors. Highers resolutions or colors support
+depends on the used browser, but most modern browsers do.
+
Note that most browsers cache favicons basically forever, so if you want
+your icon to show up, you’ll most probably have to delete you browser
+cache. Some browsers can refresh the favicon, accessing the URL
<base_url>/web_favicon/favicon.
-
You have a sample SVG that can be used as template for generating your icon
-in /static/src/img/master_original_favicon.svg. You can also search for some
-favicon generators across the web.
-
To allow a user to edit the favicon it has to be member of group “Administration / Settings”.
+
You have a sample SVG that can be used as template for generating your
+icon in /static/src/img/master_original_favicon.svg. You can also search
+for some favicon generators across the web.
+
To allow a user to edit the favicon it has to be member of group
+“Administration / Settings”.
Allow to upload some big icon (preferrably SVG or the like) and generate
-all the icons from it
-
Generate icons suitable for mobile devices and web apps (see /static/src/img/
-folder inside the module for a sample of the possible current formats.
-
Put the icon definition at system level, not at company level. It doesn’t
-make sense (as the icon is cached) to have a different icon per company.
+
Allow to upload some big icon (preferrably SVG or the like) and
+generate all the icons from it
+
Generate icons suitable for mobile devices and web apps (see
+/static/src/img/ folder inside the module for a sample of the
+possible current formats.
+
Put the icon definition at system level, not at company level. It
+doesn’t make sense (as the icon is cached) to have a different icon
+per company.
@@ -421,7 +424,7 @@ make sense (as the icon is cached) to have a different icon per company.
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.
@@ -440,7 +443,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
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.