You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015 Therp BV <http://therp.nl>
  3. # Copyright 2017 QubiQ 2010 <http://www.qubiq.es>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from io import BytesIO
  6. import base64
  7. from odoo import http
  8. from odoo.tools.misc import file_open
  9. class WebFavicon(http.Controller):
  10. @http.route('/web_favicon/favicon', type='http', auth="none")
  11. def icon(self):
  12. request = http.request
  13. if 'uid' in request.env.context:
  14. user = request.env['res.users'].browse(request.env.context['uid'])
  15. company = user.sudo(user.id).company_id
  16. else:
  17. company = request.env['res.company'].search([], limit=1)
  18. favicon = company.favicon_backend
  19. favicon_mimetype = company.favicon_backend_mimetype
  20. if not favicon:
  21. favicon = file_open('web/static/src/img/favicon.ico', 'rb')
  22. favicon_mimetype = 'image/x-icon'
  23. else:
  24. favicon = BytesIO(base64.b64decode(favicon))
  25. return request.make_response(
  26. favicon.read(), [('Content-Type', favicon_mimetype)])