|
@ -0,0 +1,80 @@
|
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
==============================
|
||||
Custom shortcut icon (favicon)
|
||||
==============================
|
||||
|
||||
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.
|
||||
|
||||
More info about favicon: https://en.wikipedia.org/wiki/Favicon
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
Upload your favicon (16x16, 32x32, 64x64 or "as big as possible") on the
|
||||
company form. The file format would be ico, gif or png with 16x16, 32x32 or
|
||||
64x64 pixels and 16 colors. Highers resolutions or colors support depends on
|
||||
the used browser, but most modern browsers do.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/162/8.0
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* Allow to upload some big icon (preferrably SVG or the like) and generate
|
||||
all the icons from it
|
||||
* Generate icons suitable for mobile devices and web apps (see /static/src/img/
|
||||
folder inside the module for a sample of the possible current formats.
|
||||
* Put the icon definition at system level, not at company level. It doesn't
|
||||
make sense (as the icon is cached) to have a different icon per company.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
|
||||
`here <https://github.com/OCA/web/issues/new?body=module:%20
|
||||
web_favicon%0Aversion:%20
|
||||
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Holger Brunn <hbrunn@therp.nl>
|
||||
* Pedro M. Baeza <pedro.baeza@gmail.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
|
@ -0,0 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import models
|
||||
from . import controllers
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Therp BV <http://therp.nl>
|
||||
# © 2016 Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "Custom shortcut icon",
|
||||
"version": "8.0.1.0.0",
|
||||
"author": "Therp BV, "
|
||||
"Tecnativa, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"category": "Website",
|
||||
"summary": "Allows to set a custom shortcut icon (aka favicon)",
|
||||
"depends": [
|
||||
'web',
|
||||
],
|
||||
"data": [
|
||||
"views/res_company.xml",
|
||||
'views/templates.xml',
|
||||
],
|
||||
"installable": True,
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import web_favicon
|
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Therp BV <http://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import StringIO
|
||||
import base64
|
||||
from openerp import http
|
||||
from openerp.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')
|
||||
favicon_mimetype = 'image/x-icon'
|
||||
else:
|
||||
favicon = StringIO.StringIO(base64.b64decode(favicon))
|
||||
return request.make_response(
|
||||
favicon.read(), [('Content-Type', favicon_mimetype)])
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import res_company
|
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Therp BV <http://therp.nl>
|
||||
# © 2016 Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, fields
|
||||
|
||||
|
||||
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.')
|
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 582 B |
After Width: | Height: | Size: 693 B |
After Width: | Height: | Size: 949 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 677 B |
After Width: | Height: | Size: 736 B |
After Width: | Height: | Size: 869 B |
After Width: | Height: | Size: 855 B |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,12 @@
|
|||
<?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>
|
After Width: | Height: | Size: 390 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 15 KiB |
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 7.1 KiB |
|
@ -0,0 +1,56 @@
|
|||
<?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>
|
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,24 @@
|
|||
<!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>
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_web_favicon
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Therp BV <http://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import base64
|
||||
from openerp.tests.common import TransactionCase
|
||||
from openerp.tools.misc import file_open
|
||||
from openerp import http
|
||||
|
||||
|
||||
class FakeRequest(object):
|
||||
def __init__(self, env):
|
||||
self.env = env
|
||||
|
||||
def make_response(self, data, headers):
|
||||
return FakeResponse(data, headers)
|
||||
|
||||
|
||||
class FakeResponse(object):
|
||||
def __init__(self, data, headers):
|
||||
self.data = data
|
||||
self.headers = dict(headers)
|
||||
|
||||
|
||||
class TestWebFavicon(TransactionCase):
|
||||
def test_web_favicon(self):
|
||||
original_request = http.request
|
||||
http.request = FakeRequest(self.env)
|
||||
from openerp.addons.web_favicon.controllers.web_favicon import\
|
||||
WebFavicon
|
||||
company = self.env['res.company'].search([], limit=1)
|
||||
# default icon
|
||||
company.write({
|
||||
'favicon_backend': False,
|
||||
'favicon_backend_mimetype': False,
|
||||
})
|
||||
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').read()),
|
||||
'favicon_backend_mimetype': 'image/png',
|
||||
})
|
||||
data = WebFavicon().icon()
|
||||
self.assertEqual(data.headers['Content-Type'],
|
||||
company.favicon_backend_mimetype)
|
||||
http.request = original_request
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<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">
|
||||
<page string="Configuration" position="inside">
|
||||
<group string="Favicon" name="favicon">
|
||||
<field name="favicon_backend" widget="image" />
|
||||
<field name="favicon_backend_mimetype" attrs="{'required': [('favicon_backend', '!=', False)]}" />
|
||||
</group>
|
||||
</page>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="layout" inherit_id="web.layout">
|
||||
<xpath expr="//link[@rel='shortcut icon']" position="replace">
|
||||
<link rel="icon" href="/web_favicon/favicon" />
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|