44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
import base64
|
|
import json
|
|
import mimetypes
|
|
|
|
from odoo import http
|
|
from odoo.exceptions import AccessError
|
|
from odoo.http import request
|
|
from odoo.tools import ustr, file_open
|
|
from odoo.addons.web.controllers.webmanifest import WebManifest as WebWebManifest
|
|
from odoo.addons.base_sparse_field.models.fields import monkey_patch
|
|
|
|
|
|
@monkey_patch(WebWebManifest)
|
|
@http.route('/web/manifest.webmanifest', type='http', auth='public', methods=['GET'])
|
|
def webmanifest(self):
|
|
""" Returns a WebManifest describing the metadata associated with a web application.
|
|
Using this metadata, user agents can provide developers with means to create user
|
|
experiences that are more comparable to that of a native application.
|
|
"""
|
|
web_app_name = request.env['ir.config_parameter'].sudo().get_param('web.web_app_name', 'Odoo')
|
|
manifest = {
|
|
'name': web_app_name,
|
|
'scope': '/web',
|
|
'start_url': '/web',
|
|
'display': 'standalone',
|
|
'background_color': '#714B67',
|
|
'theme_color': '#714B67',
|
|
'prefer_related_applications': False,
|
|
}
|
|
icon_sizes = ['192x192', '512x512']
|
|
manifest['icons'] = [{
|
|
'src': '/pwa_custom/static/src/img/c2p-icon-%s.png' % size,
|
|
'sizes': size,
|
|
'type': 'image/png',
|
|
} for size in icon_sizes]
|
|
manifest['shortcuts'] = self._get_shortcuts()
|
|
body = json.dumps(manifest, default=ustr)
|
|
response = request.make_response(body, [
|
|
('Content-Type', 'application/manifest+json'),
|
|
])
|
|
return response
|