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.

54 lines
2.5 KiB

  1. ###################################################################################
  2. #
  3. # Copyright (C) 2017 MuK IT GmbH
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as
  7. # published by the Free Software Foundation, either version 3 of the
  8. # License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. ###################################################################################
  19. import werkzeug
  20. from odoo import http
  21. from odoo.http import request
  22. from odoo.addons.web.controllers.main import make_conditional, get_last_modified
  23. from odoo.addons.web.controllers.main import manifest_glob, concat_xml
  24. from odoo.addons.web.controllers.main import WebClient
  25. class WebClient(WebClient):
  26. @http.route('/web/webclient/qweb', type='http', auth="none", cors="*")
  27. def qweb(self, mods=None, db=None):
  28. files = [f[0] for f in manifest_glob('qweb', addons=mods, db=db)]
  29. last_modified = get_last_modified(files)
  30. if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= last_modified:
  31. return werkzeug.wrappers.Response(status=304)
  32. content, checksum = concat_xml(files)
  33. if request.context and request.context.get('lang') == 'en_US':
  34. if request.session.db and request.env:
  35. content = request.env['muk_branding.debranding'].debrand(content)
  36. return make_conditional(
  37. request.make_response(content, [('Content-Type', 'text/xml')]), last_modified, checksum
  38. )
  39. @http.route('/web/webclient/translations', type='json', auth="none")
  40. def translations(self, mods=None, lang=None):
  41. res = super(WebClient, self).translations(mods, lang)
  42. for module_key, module_vals in res['modules'].items():
  43. for message in module_vals['messages']:
  44. message['id'] = request.env['muk_branding.debranding'].debrand(message['id'])
  45. message['string'] = request.env['muk_branding.debranding'].debrand(message['string'])
  46. return res