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.

29 lines
1.0 KiB

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