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.

44 lines
1.8 KiB

9 years ago
9 years ago
  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.tools.misc import file_open
  24. class WebFavicon(http.Controller):
  25. @http.route('/web_favicon/favicon', type='http', auth="none")
  26. def icon(self):
  27. request = http.request
  28. if 'uid' in request.env.context:
  29. user = request.env['res.users'].browse(request.env.context['uid'])
  30. company = user.sudo(user.id).company_id
  31. else:
  32. company = request.env['res.company'].search([], limit=1)
  33. favicon = company.favicon_backend
  34. favicon_mimetype = company.favicon_backend_mimetype
  35. if not favicon:
  36. favicon = file_open('web/static/src/img/favicon.ico')
  37. favicon_mimetype = 'image/x-icon'
  38. else:
  39. favicon = StringIO.StringIO(base64.b64decode(favicon))
  40. return request.make_response(
  41. favicon.read(), [('Content-Type', favicon_mimetype)])