diff --git a/web_favicon/README.rst b/web_favicon/README.rst index 8e5e28a735cc..6f0378d49a35 100644 --- a/web_favicon/README.rst +++ b/web_favicon/README.rst @@ -94,6 +94,13 @@ Authors * Therp BV * Tecnativa +Contributors +------------ + +- OERP Canada : + + - Daryl Chen + Maintainers ----------- diff --git a/web_favicon/__init__.py b/web_favicon/__init__.py index 185df0eec81b..69f7babdfb1a 100644 --- a/web_favicon/__init__.py +++ b/web_favicon/__init__.py @@ -1,4 +1,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models -from . import controllers diff --git a/web_favicon/__manifest__.py b/web_favicon/__manifest__.py index ef1e90eb9732..96a6d1e17cea 100644 --- a/web_favicon/__manifest__.py +++ b/web_favicon/__manifest__.py @@ -1,11 +1,15 @@ # Copyright 2015 Therp BV # Copyright 2016 Pedro M. Baeza +# Copyright 2024 OERP Canada # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Custom shortcut icon", - "version": "12.0.1.0.0", - "author": "Therp BV, " "Tecnativa, " "Odoo Community Association (OCA)", + "version": "17.0.1.0.0", + "author": "Therp BV, " + "Tecnativa, " + "OERP Canada" + "Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Website", "summary": "Allows to set a custom shortcut icon (aka favicon)", @@ -14,8 +18,7 @@ "web", ], "data": [ - "views/res_company.xml", - "views/templates.xml", + "views/res_company_view.xml", ], "installable": True, } diff --git a/web_favicon/controllers/__init__.py b/web_favicon/controllers/__init__.py deleted file mode 100644 index 7084537ab6e8..000000000000 --- a/web_favicon/controllers/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from . import web_favicon diff --git a/web_favicon/controllers/web_favicon.py b/web_favicon/controllers/web_favicon.py deleted file mode 100644 index a3d59463055f..000000000000 --- a/web_favicon/controllers/web_favicon.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2015 Therp BV -# Copyright 2017 QubiQ 2010 -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -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") - def icon(self): - request = http.request - 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) - 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" - else: - favicon = BytesIO(base64.b64decode(favicon)) - return request.make_response( - favicon.read(), [("Content-Type", favicon_mimetype)] - ) diff --git a/web_favicon/i18n/ca.po b/web_favicon/i18n/ca.po deleted file mode 100644 index e8c1e44565b7..000000000000 --- a/web_favicon/i18n/ca.po +++ /dev/null @@ -1,62 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2020-02-11 22:13+0000\n" -"Last-Translator: Carles Antoli \n" -"Language-Team: none\n" -"Language: ca\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.10\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Empreses" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "Favicon" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "Favicon del backend" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "Mimetype del favicon del backend" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "Definiu el mimetype del fitxer." - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "Favicon web" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "image/gif" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "image/png" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "image/x-icon" diff --git a/web_favicon/i18n/ca_ES.po b/web_favicon/i18n/ca_ES.po deleted file mode 100644 index f6587487e218..000000000000 --- a/web_favicon/i18n/ca_ES.po +++ /dev/null @@ -1,60 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: ca_ES\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "" diff --git a/web_favicon/i18n/da.po b/web_favicon/i18n/da.po deleted file mode 100644 index 7713498376ff..000000000000 --- a/web_favicon/i18n/da.po +++ /dev/null @@ -1,62 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2018-09-02 06:11+0000\n" -"Last-Translator: Hans Henrik Gabelgaard \n" -"Language-Team: none\n" -"Language: da\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.1.1\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Virksomheder" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "Sæt mimetypen af din fil." - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "" diff --git a/web_favicon/i18n/de.po b/web_favicon/i18n/de.po deleted file mode 100644 index b0695c774642..000000000000 --- a/web_favicon/i18n/de.po +++ /dev/null @@ -1,66 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -# Translators: -# Niki Waibel , 2016 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-22 10:37+0000\n" -"PO-Revision-Date: 2022-08-03 16:06+0000\n" -"Last-Translator: André Volksdorf \n" -"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" -"Language: de\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Unternehmen" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "Favicon" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "Icon Backend" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -#, fuzzy -msgid "Favicon Backend Mimetype" -msgstr "MIME-Type" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "Wähle den MIME-Type der Datei." - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "Web Favicon" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "image/gif" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "image/png" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "image/x-icon" diff --git a/web_favicon/i18n/es.po b/web_favicon/i18n/es.po deleted file mode 100644 index f7dbe679ac75..000000000000 --- a/web_favicon/i18n/es.po +++ /dev/null @@ -1,65 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -# Translators: -# Pedro M. Baeza , 2016 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-23 02:13+0000\n" -"PO-Revision-Date: 2021-02-17 10:45+0000\n" -"Last-Translator: claudiagn \n" -"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" -"Language: es\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Compañías" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "Favicon" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "Favicon del backend" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "Tipo MIME del favicon de backend" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "Establece el tipo MIME de su archivo." - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "Favicon web" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "image/gif" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "image/png" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "image/x-icon" diff --git a/web_favicon/i18n/hr.po b/web_favicon/i18n/hr.po deleted file mode 100644 index ccb4d1ffc17b..000000000000 --- a/web_favicon/i18n/hr.po +++ /dev/null @@ -1,68 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -# Translators: -# OCA Transbot , 2017 -# Bole , 2017 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-28 18:03+0000\n" -"PO-Revision-Date: 2017-04-28 18:03+0000\n" -"Last-Translator: Bole , 2017\n" -"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" -"Language: hr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Tvrtke" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "Favicon" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -#, fuzzy -msgid "Favicon Backend" -msgstr "Favicon backend" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -#, fuzzy -msgid "Favicon Backend Mimetype" -msgstr "Favicon backend" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "image/gif" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "image/png" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "image/x-icon" diff --git a/web_favicon/i18n/nl_NL.po b/web_favicon/i18n/nl_NL.po deleted file mode 100644 index d330c5a6a054..000000000000 --- a/web_favicon/i18n/nl_NL.po +++ /dev/null @@ -1,66 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -# Translators: -# Peter Hageman , 2017 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-07-01 03:34+0000\n" -"PO-Revision-Date: 2017-07-01 03:34+0000\n" -"Last-Translator: Peter Hageman , 2017\n" -"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" -"teams/23907/nl_NL/)\n" -"Language: nl_NL\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Bedrijven" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "Favicon" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -#, fuzzy -msgid "Favicon Backend" -msgstr "Favicon" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "Stel het afbeeldingstype in voor je bestand." - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "Web Favicon" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "afbeelding/gif" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "afbeelding/png" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "afbeelding/x-icon" diff --git a/web_favicon/i18n/pt.po b/web_favicon/i18n/pt.po deleted file mode 100644 index 777011c27ee2..000000000000 --- a/web_favicon/i18n/pt.po +++ /dev/null @@ -1,62 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2019-08-12 11:44+0000\n" -"Last-Translator: Pedro Castro Silva \n" -"Language-Team: none\n" -"Language: pt\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 3.7.1\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Empresas" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "Defina o mimetype do seu ficheiro." - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "" diff --git a/web_favicon/i18n/pt_BR.po b/web_favicon/i18n/pt_BR.po deleted file mode 100644 index 064227f1cffd..000000000000 --- a/web_favicon/i18n/pt_BR.po +++ /dev/null @@ -1,66 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -# Translators: -# Rodrigo de Almeida Sottomaior Macedo , 2017 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-06-22 08:26+0000\n" -"PO-Revision-Date: 2019-09-03 01:23+0000\n" -"Last-Translator: Rodrigo Macedo \n" -"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" -"teams/23907/pt_BR/)\n" -"Language: pt_BR\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 3.8\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Empresas" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "Ícone" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "Favicon back-end" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "Mimetype Favicon Backend" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "Defina o mimetype do seu arquivo." - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "Favicon Web" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "imagem/gif" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "imagem/png" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "imagem/x-icon" diff --git a/web_favicon/i18n/tr.po b/web_favicon/i18n/tr.po deleted file mode 100644 index c393295ab51e..000000000000 --- a/web_favicon/i18n/tr.po +++ /dev/null @@ -1,62 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-08-24 20:50+0000\n" -"Last-Translator: Ahmet Altinisik \n" -"Language-Team: none\n" -"Language: tr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2\n" - -#. module: web_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "Şirketler" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "Favicon" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "Arka taraf Favicon" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "Arka taraf Favicon mimetipi" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "Dosyanızın mimetipini ayarla." - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "Web Favicon" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "image/gif" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "image/png" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "image/x-icon" diff --git a/web_favicon/i18n/web_favicon.pot b/web_favicon/i18n/web_favicon.pot deleted file mode 100644 index fcf6fcc559c4..000000000000 --- a/web_favicon/i18n/web_favicon.pot +++ /dev/null @@ -1,60 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.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_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "" - diff --git a/web_favicon/i18n/zh_CN.po b/web_favicon/i18n/zh_CN.po deleted file mode 100644 index a6bed85e4ccf..000000000000 --- a/web_favicon/i18n/zh_CN.po +++ /dev/null @@ -1,62 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * web_favicon -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2019-09-01 12:52+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_favicon -#: model:ir.model,name:web_favicon.model_res_company -msgid "Companies" -msgstr "公司" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Favicon" -msgstr "图标" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend -msgid "Favicon Backend" -msgstr "后台图标" - -#. module: web_favicon -#: model:ir.model.fields,field_description:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Favicon Backend Mimetype" -msgstr "后台图标MIME类型" - -#. module: web_favicon -#: model:ir.model.fields,help:web_favicon.field_res_company__favicon_backend_mimetype -msgid "Set the mimetype of your file." -msgstr "设置文件的MIME类型。" - -#. module: web_favicon -#: model_terms:ir.ui.view,arch_db:web_favicon.view_company_form -msgid "Web Favicon" -msgstr "网站图标" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/gif" -msgstr "image/gif" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/png" -msgstr "image/png" - -#. module: web_favicon -#: selection:res.company,favicon_backend_mimetype:0 -msgid "image/x-icon" -msgstr "image/x-icon" diff --git a/web_favicon/models/res_company.py b/web_favicon/models/res_company.py index e101dced1259..6426293cbc41 100644 --- a/web_favicon/models/res_company.py +++ b/web_favicon/models/res_company.py @@ -1,19 +1,83 @@ # Copyright 2015 Therp BV # Copyright 2016 Pedro M. Baeza +# Copyright 2024 OERP Canada # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models +import base64 +import hashlib +import io +from random import randrange + +from PIL import Image + +import odoo +from odoo import api, fields, models, tools +from odoo.http import request class ResCompany(models.Model): _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.", + def _get_default_favicon(self, original=False): + img_path = odoo.tools.misc.file_path("web/static/img/favicon.ico") + with tools.file_open(img_path, "rb") as f: + if original: + return base64.b64encode(f.read()) + # Modify the source image to add a colored bar on the bottom + # This could seem overkill to modify the pixels 1 by 1, but + # Pillow doesn't provide an easy way to do it, and this + # is acceptable for a 16x16 image. + color = ( + randrange(32, 224, 24), + randrange(32, 224, 24), + randrange(32, 224, 24), + ) + original = Image.open(f) + new_image = Image.new("RGBA", original.size) + height = original.size[1] + width = original.size[0] + bar_size = 1 + for y in range(height): + for x in range(width): + pixel = original.getpixel((x, y)) + if height - bar_size <= y + 1 <= height: + new_image.putpixel((x, y), (color[0], color[1], color[2], 255)) + else: + new_image.putpixel( + (x, y), (pixel[0], pixel[1], pixel[2], pixel[3]) + ) + stream = io.BytesIO() + new_image.save(stream, format="ICO") + return base64.b64encode(stream.getvalue()) + + favicon = fields.Binary( + string="Company Favicon", + help="This field holds the image used to display a favicon for a given company.", + default=_get_default_favicon, ) + + @api.model_create_multi + def create(self, vals_list): + # add default favicon + for vals in vals_list: + if not vals.get("favicon"): + vals["favicon"] = self._get_default_favicon() + return super().create(vals_list) + + # Get favicon from current company + @api.model + def _get_favicon(self): + """Returns a local url that points to the image field of a given browse record.""" + company_id = ( + request.httprequest.cookies.get("cids") + if request.httprequest.cookies.get("cids") + else False + ) + if company_id and self.browse(int(company_id)).sudo().favicon: + sudo_record = self.env.company.sudo() + sha = hashlib.sha512( + str(sudo_record.write_date).encode("utf-8") + ).hexdigest()[:7] + return f"/web/image/{self._name}/{company_id}/favicon?unique={sha}" + else: + return False diff --git a/web_favicon/readme/CONFIGURE.md b/web_favicon/readme/CONFIGURE.md index 182d9d5381a8..55777b6503aa 100644 --- a/web_favicon/readme/CONFIGURE.md +++ b/web_favicon/readme/CONFIGURE.md @@ -1,16 +1,15 @@ 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 -\/web_favicon/favicon. +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". diff --git a/web_favicon/readme/CONTRIBUTORS.md b/web_favicon/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..896e5f02fea7 --- /dev/null +++ b/web_favicon/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +* OERP Canada \<\>: + - Daryl Chen \<\> diff --git a/web_favicon/readme/DESCRIPTION.md b/web_favicon/readme/DESCRIPTION.md index 8822c7c00c1b..832607856f58 100644 --- a/web_favicon/readme/DESCRIPTION.md +++ b/web_favicon/readme/DESCRIPTION.md @@ -1,9 +1,10 @@ -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. -More info about favicon: +More info about favicon: https://en.wikipedia.org/wiki/Favicon diff --git a/web_favicon/readme/ROADMAP.md b/web_favicon/readme/ROADMAP.md index 35cb8f442327..b4d00087cca8 100644 --- a/web_favicon/readme/ROADMAP.md +++ b/web_favicon/readme/ROADMAP.md @@ -1,8 +1,6 @@ -- 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. diff --git a/web_favicon/static/description/icon.png b/web_favicon/static/description/icon.png index bc0090b3d2d9..3a0328b516c4 100644 Binary files a/web_favicon/static/description/icon.png and b/web_favicon/static/description/icon.png differ diff --git a/web_favicon/static/description/index.html b/web_favicon/static/description/index.html index c162e143617b..3c71a3b27270 100644 --- a/web_favicon/static/description/index.html +++ b/web_favicon/static/description/index.html @@ -385,7 +385,8 @@

Custom shortcut icon

  • Bug Tracker
  • Credits
  • @@ -436,8 +437,17 @@

    Authors

  • Tecnativa
  • +
    +

    Contributors

    + +
    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association

    OCA, or the Odoo Community Association, is a nonprofit organization whose diff --git a/web_favicon/static/src/img/android-chrome-144x144.png b/web_favicon/static/src/img/android-chrome-144x144.png deleted file mode 100644 index 47cbf21afcea..000000000000 Binary files a/web_favicon/static/src/img/android-chrome-144x144.png and /dev/null differ diff --git a/web_favicon/static/src/img/android-chrome-192x192.png b/web_favicon/static/src/img/android-chrome-192x192.png deleted file mode 100644 index 95dd0dfc4ec9..000000000000 Binary files a/web_favicon/static/src/img/android-chrome-192x192.png and /dev/null differ diff --git a/web_favicon/static/src/img/android-chrome-36x36.png b/web_favicon/static/src/img/android-chrome-36x36.png deleted file mode 100644 index 046b7266d927..000000000000 Binary files a/web_favicon/static/src/img/android-chrome-36x36.png and /dev/null differ diff --git a/web_favicon/static/src/img/android-chrome-48x48.png b/web_favicon/static/src/img/android-chrome-48x48.png deleted file mode 100644 index 5a31a338d060..000000000000 Binary files a/web_favicon/static/src/img/android-chrome-48x48.png and /dev/null differ diff --git a/web_favicon/static/src/img/android-chrome-72x72.png b/web_favicon/static/src/img/android-chrome-72x72.png deleted file mode 100644 index 1e22c5202db4..000000000000 Binary files a/web_favicon/static/src/img/android-chrome-72x72.png and /dev/null differ diff --git a/web_favicon/static/src/img/android-chrome-96x96.png b/web_favicon/static/src/img/android-chrome-96x96.png deleted file mode 100644 index 63ba2618c2cf..000000000000 Binary files a/web_favicon/static/src/img/android-chrome-96x96.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-114x114.png b/web_favicon/static/src/img/apple-touch-icon-114x114.png deleted file mode 100644 index 0aaacd34759d..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-114x114.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-120x120.png b/web_favicon/static/src/img/apple-touch-icon-120x120.png deleted file mode 100644 index 3909ec7f00c5..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-120x120.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-144x144.png b/web_favicon/static/src/img/apple-touch-icon-144x144.png deleted file mode 100644 index f295122a6858..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-144x144.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-152x152.png b/web_favicon/static/src/img/apple-touch-icon-152x152.png deleted file mode 100644 index 93fd730ba9c0..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-152x152.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-180x180.png b/web_favicon/static/src/img/apple-touch-icon-180x180.png deleted file mode 100644 index 2899fa5da80d..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-180x180.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-57x57.png b/web_favicon/static/src/img/apple-touch-icon-57x57.png deleted file mode 100644 index 1f06b9f29d29..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-57x57.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-60x60.png b/web_favicon/static/src/img/apple-touch-icon-60x60.png deleted file mode 100644 index 715f33398295..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-60x60.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-72x72.png b/web_favicon/static/src/img/apple-touch-icon-72x72.png deleted file mode 100644 index 6e869d454532..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-72x72.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-76x76.png b/web_favicon/static/src/img/apple-touch-icon-76x76.png deleted file mode 100644 index 490ff715a538..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-76x76.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon-precomposed.png b/web_favicon/static/src/img/apple-touch-icon-precomposed.png deleted file mode 100644 index 2b3af81e8d71..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon-precomposed.png and /dev/null differ diff --git a/web_favicon/static/src/img/apple-touch-icon.png b/web_favicon/static/src/img/apple-touch-icon.png deleted file mode 100644 index 2899fa5da80d..000000000000 Binary files a/web_favicon/static/src/img/apple-touch-icon.png and /dev/null differ diff --git a/web_favicon/static/src/img/browserconfig.xml b/web_favicon/static/src/img/browserconfig.xml deleted file mode 100644 index 08e3c8951768..000000000000 --- a/web_favicon/static/src/img/browserconfig.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - #da532c - - - diff --git a/web_favicon/static/src/img/favicon-16x16.png b/web_favicon/static/src/img/favicon-16x16.png deleted file mode 100644 index b9f30800c257..000000000000 Binary files a/web_favicon/static/src/img/favicon-16x16.png and /dev/null differ diff --git a/web_favicon/static/src/img/favicon-32x32.png b/web_favicon/static/src/img/favicon-32x32.png deleted file mode 100644 index 8e73a16390f0..000000000000 Binary files a/web_favicon/static/src/img/favicon-32x32.png and /dev/null differ diff --git a/web_favicon/static/src/img/favicon-96x96.png b/web_favicon/static/src/img/favicon-96x96.png deleted file mode 100644 index 63ba2618c2cf..000000000000 Binary files a/web_favicon/static/src/img/favicon-96x96.png and /dev/null differ diff --git a/web_favicon/static/src/img/favicon.ico b/web_favicon/static/src/img/favicon.ico deleted file mode 100644 index cdf7926f9525..000000000000 Binary files a/web_favicon/static/src/img/favicon.ico and /dev/null differ diff --git a/web_favicon/static/src/img/manifest.json b/web_favicon/static/src/img/manifest.json deleted file mode 100644 index 1d8beeace5da..000000000000 --- a/web_favicon/static/src/img/manifest.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "Odoo", - "icons": [ - { - "src": "/android-chrome-36x36.png", - "sizes": "36x36", - "type": "image/png", - "density": "0.75" - }, - { - "src": "/android-chrome-48x48.png", - "sizes": "48x48", - "type": "image/png", - "density": "1.0" - }, - { - "src": "/android-chrome-72x72.png", - "sizes": "72x72", - "type": "image/png", - "density": "1.5" - }, - { - "src": "/android-chrome-96x96.png", - "sizes": "96x96", - "type": "image/png", - "density": "2.0" - }, - { - "src": "/android-chrome-144x144.png", - "sizes": "144x144", - "type": "image/png", - "density": "3.0" - }, - { - "src": "/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image/png", - "density": "4.0" - } - ] -} diff --git a/web_favicon/static/src/img/master_original_favicon.png b/web_favicon/static/src/img/master_original_favicon.png deleted file mode 100644 index 22a0aa8fb995..000000000000 Binary files a/web_favicon/static/src/img/master_original_favicon.png and /dev/null differ diff --git a/web_favicon/static/src/img/master_original_favicon.svg b/web_favicon/static/src/img/master_original_favicon.svg deleted file mode 100644 index 078a9ef3f540..000000000000 --- a/web_favicon/static/src/img/master_original_favicon.svg +++ /dev/null @@ -1,56 +0,0 @@ - - - -image/svg+xml \ No newline at end of file diff --git a/web_favicon/static/src/img/mstile-144x144.png b/web_favicon/static/src/img/mstile-144x144.png deleted file mode 100644 index e44e2367521d..000000000000 Binary files a/web_favicon/static/src/img/mstile-144x144.png and /dev/null differ diff --git a/web_favicon/static/src/img/mstile-150x150.png b/web_favicon/static/src/img/mstile-150x150.png deleted file mode 100644 index 96b4e8657477..000000000000 Binary files a/web_favicon/static/src/img/mstile-150x150.png and /dev/null differ diff --git a/web_favicon/static/src/img/mstile-310x150.png b/web_favicon/static/src/img/mstile-310x150.png deleted file mode 100644 index a924d3ffd66d..000000000000 Binary files a/web_favicon/static/src/img/mstile-310x150.png and /dev/null differ diff --git a/web_favicon/static/src/img/mstile-310x310.png b/web_favicon/static/src/img/mstile-310x310.png deleted file mode 100644 index b9b4a3e835e6..000000000000 Binary files a/web_favicon/static/src/img/mstile-310x310.png and /dev/null differ diff --git a/web_favicon/static/src/img/mstile-70x70.png b/web_favicon/static/src/img/mstile-70x70.png deleted file mode 100644 index c02805fe1800..000000000000 Binary files a/web_favicon/static/src/img/mstile-70x70.png and /dev/null differ diff --git a/web_favicon/static/src/img/website_favicon_sample.html b/web_favicon/static/src/img/website_favicon_sample.html deleted file mode 100644 index 4bda9440b147..000000000000 --- a/web_favicon/static/src/img/website_favicon_sample.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/web_favicon/tests/__init__.py b/web_favicon/tests/__init__.py index 9be3cd521afa..1581c32d0239 100644 --- a/web_favicon/tests/__init__.py +++ b/web_favicon/tests/__init__.py @@ -1,3 +1,4 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# Copyright 2024 OERP Canada +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). from . import test_web_favicon diff --git a/web_favicon/tests/test_web_favicon.py b/web_favicon/tests/test_web_favicon.py index 657b97e329b9..2d6980991938 100644 --- a/web_favicon/tests/test_web_favicon.py +++ b/web_favicon/tests/test_web_favicon.py @@ -1,52 +1,37 @@ -# Copyright 2015 Therp BV -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# Copyright 2024 OERP Canada +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) -import base64 +from PIL import Image -from odoo import http +from odoo.tests import tagged from odoo.tests.common import TransactionCase -from odoo.tools.misc import file_open +from odoo.tools import base64_to_image, image_to_base64 -class FakeRequest: - def __init__(self, env): - self.env = env - - def make_response(self, data, headers): - return FakeResponse(data, headers) - - -class FakeResponse: - def __init__(self, data, headers): - self.data = data - self.headers = dict(headers) +@tagged("post_install", "-at_install") +class TestWebFavicon(TransactionCase): + def test_01_web_favicon(self): + """The goal of this test is to make sure the favicon is correctly + handled on the backend.""" + # Test setting an Ico file directly, done through create + Company = self.env["res.company"] -class TestWebFavicon(TransactionCase): - def test_web_favicon(self): - original_request = http.request - http.request = FakeRequest(self.env) - from ..controllers.web_favicon import WebFavicon - - company = self.env["res.company"].search([], limit=1) - # default icon - company.write( + company = Company.create( { - "favicon_backend": False, - "favicon_backend_mimetype": False, + "name": "Test Company", + "favicon": Company._get_default_favicon(), } ) - data = WebFavicon().icon() - self.assertEqual(data.headers["Content-Type"], "image/x-icon") - # our own icon - company.write( - { - "favicon_backend": base64.b64encode( - file_open("web_favicon/static/description/icon.png", "rb").read() - ), - "favicon_backend_mimetype": "image/png", - } - ) - data = WebFavicon().icon() - self.assertEqual(data.headers["Content-Type"], company.favicon_backend_mimetype) - http.request = original_request + + image = base64_to_image(company.favicon) + self.assertEqual(image.format, "ICO") + + # Test setting a JPEG file that is too big, done through write + bg_color = (135, 90, 123) + image = Image.new("RGB", (1920, 1080), color=bg_color) + company.favicon = image_to_base64(image, "JPEG") + image = base64_to_image(company.favicon) + self.assertEqual(image.format, "JPEG") + self.assertEqual(image.size, (256, 256)) + self.assertEqual(image.getpixel((0, 0)), bg_color) diff --git a/web_favicon/views/res_company.xml b/web_favicon/views/res_company.xml deleted file mode 100644 index 86b49af7b661..000000000000 --- a/web_favicon/views/res_company.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - res.company - - - - - - - - - - - - - diff --git a/web_favicon/views/res_company_view.xml b/web_favicon/views/res_company_view.xml new file mode 100644 index 000000000000..761a1fb6deed --- /dev/null +++ b/web_favicon/views/res_company_view.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + res.company.form.inherit + res.company + + + + + + + + + + + diff --git a/web_favicon/views/templates.xml b/web_favicon/views/templates.xml deleted file mode 100644 index 271a46f83f8f..000000000000 --- a/web_favicon/views/templates.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - -