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.

43 lines
1.8 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # This module copyright (C) 2015 Therp BV (<http://therp.nl>).
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ##############################################################################
  20. import StringIO
  21. import base64
  22. from openerp import http
  23. from openerp.http import request
  24. from openerp.tools.misc import file_open
  25. class WebShortcutIcon(http.Controller):
  26. @http.route('/web_favicon/favicon', type='http', auth="none")
  27. def icon(self):
  28. company = request.env['res.company'].search([], limit=1)
  29. if 'uid' in request.env.context:
  30. user = request.env['res.users'].browse(request.env.context['uid'])
  31. company = user.sudo(user.id).company_id
  32. favicon = company.favicon_backend
  33. favicon_mimetype = company.favicon_backend_mimetype
  34. if not favicon:
  35. favicon = file_open('web/static/src/img/favicon.ico')
  36. favicon_mimetype = 'image/x-icon'
  37. else:
  38. favicon = StringIO.StringIO(base64.b64decode(favicon))
  39. return request.make_response(
  40. favicon.read(), [('Content-Type', favicon_mimetype)])