[MIG] web_favicon: Migration to 17.0

pull/3013/head
Daryl Chen 2024-03-14 13:35:36 -04:00 committed by Franco Leyes
parent 32b84f2079
commit 32608b070b
58 changed files with 213 additions and 1102 deletions

View File

@ -93,6 +93,14 @@ Authors
* Therp BV * Therp BV
* Tecnativa * Tecnativa
* OERP Canada
Contributors
------------
- OERP Canada <https://www.oerp.ca/>:
- Daryl Chen <dc@oerp.ca>
Maintainers Maintainers
----------- -----------

View File

@ -1,4 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models from . import models
from . import controllers

View File

@ -1,11 +1,15 @@
# Copyright 2015 Therp BV <http://therp.nl> # Copyright 2015 Therp BV <http://therp.nl>
# Copyright 2016 Pedro M. Baeza # Copyright 2016 Pedro M. Baeza
# Copyright 2024 OERP Canada <https://www.oerp.ca>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Custom shortcut icon", "name": "Custom shortcut icon",
"version": "12.0.1.0.0", "version": "17.0.1.0.0",
"author": "Therp BV, " "Tecnativa, " "Odoo Community Association (OCA)", "author": "Therp BV, "
"Tecnativa, "
"OERP Canada,"
"Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"category": "Website", "category": "Website",
"summary": "Allows to set a custom shortcut icon (aka favicon)", "summary": "Allows to set a custom shortcut icon (aka favicon)",
@ -13,9 +17,6 @@
"depends": [ "depends": [
"web", "web",
], ],
"data": [ "data": ["views/res_company_views.xml", "views/templates.xml"],
"views/res_company.xml",
"views/templates.xml",
],
"installable": True, "installable": True,
} }

View File

@ -1,3 +0,0 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import web_favicon

View File

@ -1,30 +0,0 @@
# Copyright 2015 Therp BV <http://therp.nl>
# Copyright 2017 QubiQ 2010 <http://www.qubiq.es>
# 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)]
)

View File

@ -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 <carlesantoli@hotmail.com>\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"

View File

@ -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 ""

View File

@ -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 <hhg@gabelgaard.org>\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 ""

View File

@ -1,66 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_favicon
#
# Translators:
# Niki Waibel <niki.waibel@gmail.com>, 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 <volksdorf@smartpage.de>\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"

View File

@ -1,65 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_favicon
#
# Translators:
# Pedro M. Baeza <pedro.baeza@gmail.com>, 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 <claudia.gargallo@qubiq.es>\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"

View File

@ -1,68 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_favicon
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# Bole <bole@dajmi5.com>, 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 <bole@dajmi5.com>, 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"

View File

@ -1,66 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_favicon
#
# Translators:
# Peter Hageman <hageman.p@gmail.com>, 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 <hageman.p@gmail.com>, 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"

View File

@ -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 <pedrocs@exo.pt>\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 ""

View File

@ -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 <rmsolucoeseminformatic4@gmail.com>, 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 <rmsolucoeseminformatic4@gmail.com>\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"

View File

@ -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 <aaltinisik@altinkaya.com.tr>\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"

View File

@ -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 ""

View File

@ -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"

View File

@ -1,19 +1,87 @@
# Copyright 2015 Therp BV <http://therp.nl> # Copyright 2015 Therp BV <http://therp.nl>
# Copyright 2016 Pedro M. Baeza # Copyright 2016 Pedro M. Baeza
# Copyright 2024 OERP Canada <https://www.oerp.ca>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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): class ResCompany(models.Model):
_inherit = "res.company" _inherit = "res.company"
favicon_backend = fields.Binary() def _get_default_favicon(self, original=False):
favicon_backend_mimetype = fields.Selection( img_path = odoo.tools.misc.file_path("web/static/img/favicon.ico")
selection=[ with tools.file_open(img_path, "rb") as f:
("image/x-icon", "image/x-icon"), if original:
("image/gif", "image/gif"), return base64.b64encode(f.read())
("image/png", "image/png"), # Modify the source image to add a colored bar on the bottom
], # This could seem overkill to modify the pixels 1 by 1, but
help="Set the mimetype of your file.", # 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 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 record."""
company_id = (
request.httprequest.cookies.get("cids")
if request.httprequest.cookies.get("cids")
else False
)
company = (
self.browse(int(company_id.split(",")[0])).sudo()
if company_id and self.browse(int(company_id.split(",")[0])).sudo().favicon
else False
)
if company:
sha = hashlib.sha512(str(company.write_date).encode("utf-8")).hexdigest()[
:7
]
return f"/web/image/{self._name}/{company_id}/favicon?unique={sha}"
else:
return False

View File

@ -1,16 +1,15 @@
Upload your favicon (16x16, 32x32, 64x64 or "as big as possible") on the 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 company form. The file format would be ico, gif or png with 16x16, 32x32 or
or 64x64 pixels and 16 colors. Highers resolutions or colors support 64x64 pixels and 16 colors. Highers resolutions or colors support depends on
depends on the used browser, but most modern browsers do. the used browser, but most modern browsers do.
Note that most browsers cache favicons basically forever, so if you want Note that most browsers cache favicons basically forever, so if you want your
your icon to show up, you'll most probably have to delete you browser icon to show up, you'll most probably have to delete you browser cache.
cache. Some browsers can refresh the favicon, accessing the URL Some browsers can refresh the favicon, accessing the URL
\<base_url\>/web_favicon/favicon. <base_url>/web_favicon/favicon.
You have a sample SVG that can be used as template for generating your You have a sample SVG that can be used as template for generating your icon
icon in /static/src/img/master_original_favicon.svg. You can also search in /static/src/img/master_original_favicon.svg. You can also search for some
for some favicon generators across the web. favicon generators across the web.
To allow a user to edit the favicon it has to be member of group To allow a user to edit the favicon it has to be member of group "Administration / Settings".
"Administration / Settings".

View File

@ -0,0 +1,2 @@
* OERP Canada \<<https://www.oerp.ca/>\>:
- Daryl Chen \<<dc@oerp.ca>\>

View File

@ -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 This module was written to allow you to customize your Odoo instance's shortcut
also for integrators who have many different Odoo instances running and icon (aka favicon). This is useful for branding purposes, but also for
need to see at a glance which browser tab does what. 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 The icon is shown also for portal users when the website modules are not
installed. installed.
More info about favicon: <https://en.wikipedia.org/wiki/Favicon> More info about favicon: https://en.wikipedia.org/wiki/Favicon

View File

@ -1,8 +1,6 @@
- Allow to upload some big icon (preferrably SVG or the like) and * Allow to upload some big icon (preferrably SVG or the like) and generate
generate all the icons from it all the icons from it
- Generate icons suitable for mobile devices and web apps (see * Generate icons suitable for mobile devices and web apps (see /static/src/img/
/static/src/img/ folder inside the module for a sample of the possible folder inside the module for a sample of the possible current formats.
current formats. * Put the icon definition at system level, not at company level. It doesn't
- Put the icon definition at system level, not at company level. It make sense (as the icon is cached) to have a different icon per company.
doesn't make sense (as the icon is cached) to have a different icon
per company.

View File

@ -9,10 +9,11 @@
/* /*
:Author: David Goodger (goodger@python.org) :Author: David Goodger (goodger@python.org)
: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. :Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils. 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 See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
@ -275,7 +276,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ; margin-left: 2em ;
margin-right: 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, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 } pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@ -301,7 +302,7 @@ span.option {
span.pre { span.pre {
white-space: pre } white-space: pre }
span.problematic { span.problematic, pre.problematic {
color: red } color: red }
span.section-subtitle { span.section-subtitle {
@ -385,7 +386,8 @@ installed.</p>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li> <li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul> <li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li> <li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li> <li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -434,12 +436,24 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<ul class="simple"> <ul class="simple">
<li>Therp BV</li> <li>Therp BV</li>
<li>Tecnativa</li> <li>Tecnativa</li>
<li>OERP Canada</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>OERP Canada &lt;<a class="reference external" href="https://www.oerp.ca/">https://www.oerp.ca/</a>&gt;:<ul>
<li>Daryl Chen &lt;<a class="reference external" href="mailto:dc&#64;oerp.ca">dc&#64;oerp.ca</a>&gt;</li>
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2> <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <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 <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/mstile-70x70.png" />
<square150x150logo src="/mstile-150x150.png" />
<square310x310logo src="/mstile-310x310.png" />
<wide310x150logo src="/mstile-310x150.png" />
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -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"
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg2"
version="1.1"
inkscape:version="0.48.4 r9939"
width="260"
height="260"
xml:space="preserve"
sodipodi:docname="master_original_favicon.svg"
inkscape:export-filename="master_original_favicon.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"><metadata
id="metadata8"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs6" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1861"
inkscape:window-height="1176"
id="namedview4"
showgrid="false"
inkscape:zoom="2.6264843"
inkscape:cx="139.55902"
inkscape:cy="63.525562"
inkscape:window-x="59"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="g10"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" /><g
id="g10"
inkscape:groupmode="layer"
inkscape:label="ink_ext_XXXXXX"
transform="matrix(1.25,0,0,-1.25,0,260)"><path
inkscape:connector-curvature="0"
id="path14"
style="fill:#a2478a;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 104.00014,165.45424 c -8.313043,0 -16.263246,-1.57861 -23.850744,-4.72609 -7.594015,-3.15718 -14.181554,-7.52151 -19.768717,-13.10966 -5.587026,-5.58537 -10.031894,-12.10596 -13.321854,-19.55278 -3.297028,-7.45376 -4.942836,-15.61837 -4.942836,-24.4966 0,-8.312905 1.645808,-16.26269 4.942836,-23.850746 3.28996,-7.594012 7.734828,-14.256255 13.321854,-19.984093 5.587163,-5.733797 12.174702,-10.246299 19.768717,-13.536809 7.587498,-3.297027 15.537701,-4.941729 23.850744,-4.941729 8.30583,0 16.2577,1.644702 23.85171,4.941729 7.5875,3.29051 14.18128,7.803012 19.76942,13.536809 5.58675,5.727838 10.02454,12.390081 13.32171,19.984093 3.29023,7.588056 4.94089,15.537841 4.94089,23.850746 -0.85928,16.90258 -6.87567,31.15898 -18.04779,42.76184 -11.17419,11.60314 -25.6454,17.97571 -43.40561,19.12329 l -0.43033,0 z M 104.43047,208 c 14.03437,0 27.28859,-2.79405 39.75226,-8.38083 12.46244,-5.58534 23.4211,-13.10687 32.87602,-22.5618 9.45355,-9.45492 16.97508,-20.48705 22.56183,-33.09085 C 205.20733,131.3558 208,117.89258 208,103.56911 208,89.239815 205.27385,75.85019 199.83679,63.387487 194.39,50.925336 187.01124,39.966662 177.70323,30.511325 168.38966,21.056678 157.431,13.602838 144.82719,8.1646355 132.21703,2.726419 118.61203,0 104.00014,0 89.671258,0 76.208041,2.5780813 63.603558,7.7347705 50.993109,12.892 39.96777,20.123798 30.512431,29.437215 21.058202,38.744259 13.605015,49.702934 8.1651761,62.313379 2.7204595,74.917448 0,88.668665 0,103.56911 c 0,14.32347 2.6462976,27.71892 7.9502436,40.1826 5.2990814,12.46381 12.6781754,23.34765 22.1335154,32.66119 9.453538,9.30801 20.553026,16.76025 33.305391,22.347 12.744188,5.58675 26.429298,8.66218 41.04132,9.2401" /></g></svg>

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,84 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
<head profile="http://www.w3.org/2005/10/profile">
<link
rel="shortcut icon"
href="/website_favicon/static/src/img/favicon.ico"
type="image/x-icon"
/>
<link
rel="apple-touch-icon"
sizes="57x57"
href="/website_favicon/static/src/img/apple-touch-icon-57x57.png"
/>
<link
rel="apple-touch-icon"
sizes="60x60"
href="/website_favicon/static/src/img/apple-touch-icon-60x60.png"
/>
<link
rel="apple-touch-icon"
sizes="72x72"
href="/website_favicon/static/src/img/apple-touch-icon-72x72.png"
/>
<link
rel="apple-touch-icon"
sizes="76x76"
href="/website_favicon/static/src/img/apple-touch-icon-76x76.png"
/>
<link
rel="apple-touch-icon"
sizes="114x114"
href="/website_favicon/static/src/img/apple-touch-icon-114x114.png"
/>
<link
rel="apple-touch-icon"
sizes="120x120"
href="/website_favicon/static/src/img/apple-touch-icon-120x120.png"
/>
<link
rel="apple-touch-icon"
sizes="144x144"
href="/website_favicon/static/src/img/apple-touch-icon-144x144.png"
/>
<link
rel="apple-touch-icon"
sizes="152x152"
href="/website_favicon/static/src/img/apple-touch-icon-152x152.png"
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="/website_favicon/static/src/img/apple-touch-icon-180x180.png"
/>
<link
rel="icon"
type="image/png"
href="/website_favicon/static/src/img/favicon-32x32.png"
sizes="32x32"
/>
<link
rel="icon"
type="image/png"
href="/website_favicon/static/src/img/android-chrome-192x192.png"
sizes="192x192"
/>
<link
rel="icon"
type="image/png"
href="/website_favicon/static/src/img/favicon-96x96.png"
sizes="96x96"
/>
<link
rel="icon"
type="image/png"
href="/website_favicon/static/src/img/favicon-16x16.png"
sizes="16x16"
/>
<link rel="manifest" href="/manifest.json" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="msapplication-TileImage" content="/mstile-144x144.png" />
<meta name="theme-color" content="#ffffff" />
</head>
<body />
</html>

View File

@ -1,52 +1,48 @@
# Copyright 2015 Therp BV <http://therp.nl> # Copyright 2024 OERP Canada <https://www.oerp.ca>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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.tests.common import TransactionCase
from odoo.tools.misc import file_open from odoo.tools import base64_to_image, image_to_base64
from odoo.addons.website.tools import MockRequest
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): class TestWebFavicon(TransactionCase):
def test_web_favicon(self): def test_01_web_favicon(self):
original_request = http.request """The goal of this test is to make sure the favicon is correctly
http.request = FakeRequest(self.env) handled on the backend."""
from ..controllers.web_favicon import WebFavicon
company = self.env["res.company"].search([], limit=1) # Test setting an Ico file directly, done through create
# default icon Company = self.env["res.company"]
company.write(
company = Company.create(
{ {
"favicon_backend": False, "name": "Test Company",
"favicon_backend_mimetype": False, "favicon": Company._get_default_favicon(),
} }
) )
data = WebFavicon().icon()
self.assertEqual(data.headers["Content-Type"], "image/x-icon") image = base64_to_image(company.favicon)
# our own icon self.assertEqual(image.format, "ICO")
company.write(
{ # Test setting a JPEG file that is too big, done through write
"favicon_backend": base64.b64encode( bg_color = (135, 90, 123)
file_open("web_favicon/static/description/icon.png", "rb").read() image = Image.new("RGB", (1920, 1080), color=bg_color)
), company.favicon = image_to_base64(image, "JPEG")
"favicon_backend_mimetype": "image/png", image = base64_to_image(company.favicon)
} self.assertEqual(image.format, "JPEG")
) self.assertEqual(image.size, (1920, 1080))
data = WebFavicon().icon() self.assertEqual(image.getpixel((0, 0)), bg_color)
self.assertEqual(data.headers["Content-Type"], company.favicon_backend_mimetype) with MockRequest(self.env) as mock_request:
http.request = original_request mock_request.httprequest.cookies = {"cids": str(company.id)}
self.assertTrue(Company._get_favicon())
def test_02_default_favicon_creation(self):
"""Test if default favicon is set when creating a company without favicon."""
Company = self.env["res.company"]
company = Company.create({"name": "Test Company"})
self.assertTrue(company.favicon, "Default favicon not set on company creation.")

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_company_form" model="ir.ui.view">
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<notebook position="inside">
<page string="Web Favicon" name="favicon" groups="base.group_system">
<group string="Favicon" name="favicon">
<field name="favicon_backend" widget="image" />
<field
name="favicon_backend_mimetype"
attrs="{'required': [('favicon_backend', '!=', False)]}"
/>
</group>
</page>
</notebook>
</field>
</record>
</odoo>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 OERP Canada <https://www.oerp.ca>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<data noupdate="1">
<record id="base.main_company" model="res.company">
<field
name="favicon"
model="res.company"
eval="obj()._get_default_favicon(original=True)"
/>
</record>
</data>
<record id="view_company_form_inherit" model="ir.ui.view">
<field name="name">res.company.form.inherit</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='color']" position="after">
<field
name="favicon"
widget="image"
class="float-start oe_avatar"
groups="base.group_no_one"
/>
</xpath>
</field>
</record>
</odoo>

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 OERP Canada <https://www.oerp.ca>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<template id="layout" inherit_id="web.layout"> <template id="favicon_icon" inherit_id="web.layout" name="Web layout">
<xpath expr="//link[@rel='shortcut icon']" position="before"> <xpath expr="//head/link[@rel='shortcut icon']" position="attributes">
<t t-if="not website"> <attribute
<t t-set="x_icon" t-value="'/web_favicon/favicon'" /> name="t-att-href"
</t> >env['res.company'].sudo()._get_favicon() or '/web/static/img/favicon.ico'</attribute>
</xpath> </xpath>
</template> </template>
</odoo> </odoo>