Merge PR #2310 into 15.0
Signed-off-by pedrobaeza15.0-ocabot-merge-pr-2789-by-pedrobaeza-bump-patch
|
@ -0,0 +1 @@
|
|||
../../../../web_pwa_oca
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -0,0 +1,192 @@
|
|||
===========================
|
||||
Progressive web application
|
||||
===========================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/web/tree/15.0/web_pwa_oca
|
||||
:alt: OCA/web
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_pwa_oca
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/162/15.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
Make Odoo an installable Progressive Web Application.
|
||||
|
||||
Progressive Web Apps provide an installable, app-like experience on desktop and mobile that are built and delivered directly via the web.
|
||||
They're web apps that are fast and reliable. And most importantly, they're web apps that work in any browser.
|
||||
If you're building a web app today, you're already on the path towards building a Progressive Web App.
|
||||
|
||||
|
||||
+ Developers Info.
|
||||
|
||||
The service worker is contructed using 'Odoo Class' to have the same class inheritance behaviour that in the 'user pages'. Be noticed
|
||||
that 'Odoo Bootstrap' is not supported so, you can't use 'require' here.
|
||||
|
||||
All service worker content can be found in 'static/src/js/worker'. The management between 'user pages' and service worker is done in
|
||||
'pwa_manager.js'.
|
||||
|
||||
The purpose of this module is give a base to make PWA applications.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
After having installed this module, browsing your odoo on mobile you will be able to install it as a PWA.
|
||||
|
||||
It is strongly recommended to use this module with a responsive layout, like the one provided by web_responsive.
|
||||
|
||||
This module is intended to be used by Odoo back-end users (employees).
|
||||
|
||||
When a Progressive Web App is installed, it looks and behaves like all of the other installed apps.
|
||||
It launches from the same place that other apps launch. It runs in an app without an address bar or other browser UI.
|
||||
And like all other installed apps, it's a top level app in the task switcher.
|
||||
|
||||
In Chrome, a Progressive Web App can either be installed through the three-dot context menu.
|
||||
|
||||
In case you previously installed `web_pwa`, run the following steps with `odoo shell`, after having installed `openupgradelib`:
|
||||
|
||||
|
||||
>>> from openupgradelib import openupgrade
|
||||
>>> openupgrade.update_module_names(env.cr, [('web_pwa', 'web_pwa_oca')], merge_modules=False)
|
||||
>>> env.cr.commit()
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
This module allows you to set the following parameters under settings to customize the appearance of the application
|
||||
|
||||
* PWA Name (defaults to "Odoo PWA")
|
||||
* PWA Short Name (defaults to "Odoo PWA")
|
||||
* PWA Icon (**SVG**) (defaults to "/web_pwa_oca/static/img/icons/odoo-logo.svg")
|
||||
|
||||
To configure your PWA:
|
||||
|
||||
#. Go to **Settings > General Settings > Progressive Web App**.
|
||||
#. Set the parameters (*Note:* Icon **must be a SVG file**)
|
||||
#. **Save**
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use your PWA:
|
||||
|
||||
#. Open the Odoo web app using a supported browser (See https://caniuse.com/?search=A2HS)
|
||||
#. Open the browser options
|
||||
#. Click on 'Add to Home screen' (or 'Install' in other browsers)
|
||||
|
||||
** Maybe you need refresh the page to load the service worker after using the option.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* Integrate `Notification API <https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification>`_
|
||||
* Integrate `Web Share API <https://web.dev/web-share/>`_
|
||||
* Create ``portal_pwa`` module, intended to be used by front-end users (customers, suppliers...)
|
||||
* Current *John Resig's inheritance* implementation doesn't support ``async``
|
||||
functions because ``this._super`` can't be called inside a promise. So we
|
||||
need to use the following workaround:
|
||||
|
||||
- Natural 'async/await' example (This breaks "_super" call):
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var MyClass = OdooClass.extend({
|
||||
myFunc: async function() {
|
||||
const mydata = await ...do await stuff...
|
||||
return mydata;
|
||||
}
|
||||
});
|
||||
|
||||
- Same code with the workaround:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var MyClass = OdooClass.extend({
|
||||
myFunc: function() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const mydata = await ...do await stuff...
|
||||
return resolve(mydata);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
* Fix issue when trying to run in localhost with several databases. The browser
|
||||
doesn't send the cookie and web manifest returns 404.
|
||||
* Firefox can't detect 'standalone' mode. See https://bugzilla.mozilla.org/show_bug.cgi?id=1285858
|
||||
* Firefox disable service worker in private mode. See https://bugzilla.mozilla.org/show_bug.cgi?id=1601916
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_pwa_oca%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* TAKOBI
|
||||
* Tecnativa
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* `TAKOBI <https://takobi.online>`_:
|
||||
|
||||
* Lorenzo Battistini
|
||||
|
||||
* `Tecnativa <https://tecnativa.com>`_:
|
||||
|
||||
* Alexandre D. Díaz
|
||||
* João Marques
|
||||
* Sergio Teruel
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
.. |maintainer-eLBati| image:: https://github.com/eLBati.png?size=40px
|
||||
:target: https://github.com/eLBati
|
||||
:alt: eLBati
|
||||
|
||||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-eLBati|
|
||||
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/15.0/web_pwa_oca>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
|
@ -0,0 +1,2 @@
|
|||
from . import controllers
|
||||
from . import models
|
|
@ -0,0 +1,27 @@
|
|||
# Copyright 2020 Lorenzo Battistini @ TAKOBI
|
||||
# Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||
# Copyright 2020 Tecnativa - João Marques
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
|
||||
{
|
||||
"name": "Progressive web application",
|
||||
"summary": "Make Odoo a PWA",
|
||||
"version": "15.0.1.0.0",
|
||||
"development_status": "Beta",
|
||||
"category": "Website",
|
||||
"website": "https://github.com/OCA/web",
|
||||
"author": "TAKOBI, Tecnativa, Odoo Community Association (OCA)",
|
||||
"maintainers": ["eLBati"],
|
||||
"license": "LGPL-3",
|
||||
"application": True,
|
||||
"installable": True,
|
||||
"depends": ["web", "mail"],
|
||||
"data": ["templates/assets.xml", "views/res_config_settings_views.xml"],
|
||||
"assets": {
|
||||
"web.assets_backend": [
|
||||
"/web_pwa_oca/static/src/js/pwa_manager.js",
|
||||
"/web_pwa_oca/static/src/js/webclient.js",
|
||||
]
|
||||
},
|
||||
"images": ["static/description/pwa.png"],
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright 2020 Lorenzo Battistini @ TAKOBI
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
from . import main
|
||||
from . import service_worker
|
|
@ -0,0 +1,120 @@
|
|||
# Copyright 2020 Lorenzo Battistini @ TAKOBI
|
||||
# Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||
# Copyright 2020 Tecnativa - João Marques
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
import json
|
||||
|
||||
from odoo.http import Controller, request, route
|
||||
|
||||
|
||||
class PWA(Controller):
|
||||
def _get_pwa_scripts(self):
|
||||
"""Scripts to be imported in the service worker (Order is important)"""
|
||||
return [
|
||||
"/web/static/lib/underscore/underscore.js",
|
||||
"/web_pwa_oca/static/src/js/worker/jquery-sw-compat.js",
|
||||
"/web/static/src/legacy/js/promise_extension.js",
|
||||
"/web/static/src/boot.js",
|
||||
"/web/static/src/legacy/js/core/class.js",
|
||||
"/web_pwa_oca/static/src/js/worker/pwa.js",
|
||||
]
|
||||
|
||||
@route("/service-worker.js", type="http", auth="public")
|
||||
def render_service_worker(self):
|
||||
"""Route to register the service worker in the 'main' scope ('/')"""
|
||||
return request.render(
|
||||
"web_pwa_oca.service_worker",
|
||||
{
|
||||
"pwa_scripts": self._get_pwa_scripts(),
|
||||
"pwa_params": self._get_pwa_params(),
|
||||
},
|
||||
headers=[("Content-Type", "text/javascript;charset=utf-8")],
|
||||
)
|
||||
|
||||
def _get_pwa_params(self):
|
||||
"""Get javascript PWA class initialzation params"""
|
||||
return {}
|
||||
|
||||
def _get_pwa_manifest_icons(self, pwa_icon):
|
||||
icons = []
|
||||
if not pwa_icon:
|
||||
for size in [
|
||||
(128, 128),
|
||||
(144, 144),
|
||||
(152, 152),
|
||||
(192, 192),
|
||||
(256, 256),
|
||||
(512, 512),
|
||||
]:
|
||||
icons.append(
|
||||
{
|
||||
"src": "/web_pwa_oca/static/img/icons/icon-%sx%s.png"
|
||||
% (str(size[0]), str(size[1])),
|
||||
"sizes": "{}x{}".format(str(size[0]), str(size[1])),
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable",
|
||||
}
|
||||
)
|
||||
elif not pwa_icon.mimetype.startswith("image/svg"):
|
||||
all_icons = (
|
||||
request.env["ir.attachment"]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("url", "like", "/web_pwa_oca/icon"),
|
||||
(
|
||||
"url",
|
||||
"not like",
|
||||
"/web_pwa_oca/icon.",
|
||||
), # Get only resized icons
|
||||
]
|
||||
)
|
||||
)
|
||||
for icon in all_icons:
|
||||
icon_size_name = icon.url.split("/")[-1].lstrip("icon").split(".")[0]
|
||||
icons.append(
|
||||
{"src": icon.url, "sizes": icon_size_name, "type": icon.mimetype}
|
||||
)
|
||||
else:
|
||||
icons = [
|
||||
{
|
||||
"src": pwa_icon.url,
|
||||
"sizes": "128x128 144x144 152x152 192x192 256x256 512x512",
|
||||
"type": pwa_icon.mimetype,
|
||||
}
|
||||
]
|
||||
return icons
|
||||
|
||||
def _get_pwa_manifest(self):
|
||||
"""Webapp manifest"""
|
||||
config_param_sudo = request.env["ir.config_parameter"].sudo()
|
||||
pwa_name = config_param_sudo.get_param("pwa.manifest.name", "Odoo PWA")
|
||||
pwa_short_name = config_param_sudo.get_param(
|
||||
"pwa.manifest.short_name", "Odoo PWA"
|
||||
)
|
||||
pwa_icon = (
|
||||
request.env["ir.attachment"]
|
||||
.sudo()
|
||||
.search([("url", "like", "/web_pwa_oca/icon.")])
|
||||
)
|
||||
background_color = config_param_sudo.get_param(
|
||||
"pwa.manifest.background_color", "#2E69B5"
|
||||
)
|
||||
theme_color = config_param_sudo.get_param("pwa.manifest.theme_color", "#2E69B5")
|
||||
return {
|
||||
"name": pwa_name,
|
||||
"short_name": pwa_short_name,
|
||||
"icons": self._get_pwa_manifest_icons(pwa_icon),
|
||||
"start_url": "/web",
|
||||
"display": "standalone",
|
||||
"background_color": background_color,
|
||||
"theme_color": theme_color,
|
||||
}
|
||||
|
||||
@route("/web_pwa_oca/manifest.webmanifest", type="http", auth="public")
|
||||
def pwa_manifest(self):
|
||||
"""Returns the manifest used to install the page as app"""
|
||||
return request.make_response(
|
||||
json.dumps(self._get_pwa_manifest()),
|
||||
headers=[("Content-Type", "application/json;charset=utf-8")],
|
||||
)
|
|
@ -0,0 +1,106 @@
|
|||
# Copyright 2021 Tecnativa - Alexandre D. Díaz
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
from odoo.http import request, route
|
||||
|
||||
from .main import PWA
|
||||
|
||||
|
||||
class ServiceWorker(PWA):
|
||||
|
||||
JS_PWA_CORE_EVENT_INSTALL = """
|
||||
self.addEventListener('install', evt => {{
|
||||
console.log('[ServiceWorker] Installing...');
|
||||
{}
|
||||
}});
|
||||
"""
|
||||
|
||||
JS_PWA_CORE_EVENT_FETCH = """
|
||||
self.addEventListener('fetch', evt => {{
|
||||
{}
|
||||
}});
|
||||
"""
|
||||
|
||||
JS_PWA_CORE_EVENT_ACTIVATE = """
|
||||
self.addEventListener('activate', evt => {{
|
||||
{}
|
||||
}});
|
||||
"""
|
||||
|
||||
JS_PWA_MAIN = """
|
||||
self.importScripts(...{pwa_scripts});
|
||||
|
||||
odoo.define("web_pwa_oca.ServiceWorker", function (require) {{
|
||||
"use strict";
|
||||
|
||||
{pwa_requires}
|
||||
|
||||
{pwa_init}
|
||||
{pwa_core_event_install}
|
||||
{pwa_core_event_activate}
|
||||
{pwa_core_event_fetch}
|
||||
}});
|
||||
"""
|
||||
|
||||
def _get_js_pwa_requires(self):
|
||||
return """
|
||||
const PWA = require('web_pwa_oca.PWA');
|
||||
"""
|
||||
|
||||
def _get_js_pwa_init(self):
|
||||
return """
|
||||
let promise_start = Promise.resolve();
|
||||
if (typeof self.oca_pwa === "undefined") {{
|
||||
self.oca_pwa = new PWA({});
|
||||
promise_start = self.oca_pwa.start();
|
||||
if (self.serviceWorker.state === "activated") {{
|
||||
promise_start = promise_start.then(
|
||||
() => self.oca_pwa.activateWorker(true));
|
||||
}}
|
||||
}}
|
||||
""".format(
|
||||
self._get_pwa_params()
|
||||
)
|
||||
|
||||
def _get_js_pwa_core_event_install_impl(self):
|
||||
return """
|
||||
evt.waitUntil(oca_pwa.installWorker());
|
||||
self.skipWaiting();
|
||||
"""
|
||||
|
||||
def _get_js_pwa_core_event_activate_impl(self):
|
||||
return """
|
||||
console.log('[ServiceWorker] Activating...');
|
||||
evt.waitUntil(oca_pwa.activateWorker());
|
||||
self.clients.claim();
|
||||
"""
|
||||
|
||||
def _get_js_pwa_core_event_fetch_impl(self):
|
||||
return ""
|
||||
|
||||
@route("/service-worker.js", type="http", auth="public")
|
||||
def render_service_worker(self):
|
||||
"""Route to register the service worker in the 'main' scope ('/')"""
|
||||
|
||||
sw_code = self.JS_PWA_MAIN.format(
|
||||
**{
|
||||
"pwa_scripts": self._get_pwa_scripts(),
|
||||
"pwa_requires": self._get_js_pwa_requires(),
|
||||
"pwa_init": self._get_js_pwa_init(),
|
||||
"pwa_core_event_install": self.JS_PWA_CORE_EVENT_INSTALL.format(
|
||||
self._get_js_pwa_core_event_install_impl()
|
||||
),
|
||||
"pwa_core_event_activate": self.JS_PWA_CORE_EVENT_ACTIVATE.format(
|
||||
self._get_js_pwa_core_event_activate_impl()
|
||||
),
|
||||
"pwa_core_event_fetch": self.JS_PWA_CORE_EVENT_FETCH.format(
|
||||
self._get_js_pwa_core_event_fetch_impl()
|
||||
),
|
||||
}
|
||||
)
|
||||
return request.make_response(
|
||||
sw_code,
|
||||
[
|
||||
("Content-Type", "text/javascript;charset=utf-8"),
|
||||
("Content-Length", len(sw_code)),
|
||||
],
|
||||
)
|
|
@ -0,0 +1,143 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_pwa_oca
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 13.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-03-16 18:49+0000\n"
|
||||
"PO-Revision-Date: 2021-03-16 19:50+0100\n"
|
||||
"Last-Translator: claudiagn <claudia.gargallo@qubiq.es>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: es\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Poedit 2.4.1\n"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_background_color
|
||||
#, fuzzy
|
||||
msgid "Background Color"
|
||||
msgstr "Color de fondo"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model,name:web_pwa_oca.model_res_config_settings
|
||||
#, fuzzy
|
||||
msgid "Config Settings"
|
||||
msgstr "Ajustes de configuración"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_icon
|
||||
#, fuzzy
|
||||
msgid "Icon"
|
||||
msgstr "Icono"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
#, fuzzy
|
||||
msgid "Name"
|
||||
msgstr "Nombre"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
#, fuzzy
|
||||
msgid "Name and icon of your PWA"
|
||||
msgstr "Nombre e icono de su PWA"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,help:web_pwa_oca.field_res_config_settings__pwa_name
|
||||
#, fuzzy
|
||||
msgid "Name of the Progressive Web Application"
|
||||
msgstr "Nombre de la aplicación web progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
#, fuzzy
|
||||
msgid "PWA Title"
|
||||
msgstr "Título de PWA"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
#, fuzzy
|
||||
msgid "Progressive Web App"
|
||||
msgstr "Aplicación web progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_name
|
||||
#, fuzzy
|
||||
msgid "Progressive Web App Name"
|
||||
msgstr "Nombre de la aplicación web progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_short_name
|
||||
#, fuzzy
|
||||
msgid "Progressive Web App Short Name"
|
||||
msgstr "Nombre corto de la aplicación web progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, fuzzy, python-format
|
||||
msgid ""
|
||||
"Service workers are not supported! Maybe you are not using HTTPS or you work "
|
||||
"in private mode."
|
||||
msgstr ""
|
||||
"¡Los trabajadores de servicios no son compatibles! Quizás no esté usando "
|
||||
"HTTPS o trabaje en modo privado."
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
#, fuzzy
|
||||
msgid "Short Name"
|
||||
msgstr "Nombre corto"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,help:web_pwa_oca.field_res_config_settings__pwa_short_name
|
||||
#, fuzzy
|
||||
msgid "Short Name of the Progressive Web Application"
|
||||
msgstr "Nombre corto de la aplicación web progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_theme_color
|
||||
#, fuzzy
|
||||
msgid "Theme Color"
|
||||
msgstr "Color del tema"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, fuzzy, python-format
|
||||
msgid "You can only upload PNG files bigger than 512x512"
|
||||
msgstr "Solo puede cargar archivos PNG de más de 512 x 512"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can only upload SVG or PNG files. Found: %s."
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, fuzzy, python-format
|
||||
msgid "You can't upload a file with more than 2 MB."
|
||||
msgstr "No puede cargar un archivo con más de 2 MB."
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, fuzzy, python-format
|
||||
msgid "[ServiceWorker] Registered:"
|
||||
msgstr "[ServiceWorker] Registrada:"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid "[ServiceWorker] Registration failed: "
|
||||
msgstr "[ServiceWorker] Error en el registro: "
|
||||
|
||||
#, fuzzy
|
||||
#~ msgid "You can only upload SVG or PNG files"
|
||||
#~ msgstr "Solo puede cargar archivos SVG o PNG"
|
|
@ -0,0 +1,128 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_pwa_oca
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 13.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2021-11-20 20:36+0000\n"
|
||||
"Last-Translator: Ignacio Buioli <ibuioli@gmail.com>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: es_AR\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 4.3.2\n"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_background_color
|
||||
msgid "Background Color"
|
||||
msgstr "Color de Fondo"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model,name:web_pwa_oca.model_res_config_settings
|
||||
msgid "Config Settings"
|
||||
msgstr "Configurar Ajustes"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_icon
|
||||
msgid "Icon"
|
||||
msgstr "Ícono"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Name"
|
||||
msgstr "Nombre"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Name and icon of your PWA"
|
||||
msgstr "Nombre e ícono para su PWA"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,help:web_pwa_oca.field_res_config_settings__pwa_name
|
||||
msgid "Name of the Progressive Web Application"
|
||||
msgstr "Nombre de la Aplicación Web Progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "PWA Title"
|
||||
msgstr "Título del PWA"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Progressive Web App"
|
||||
msgstr "Aplicación Web Progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_name
|
||||
msgid "Progressive Web App Name"
|
||||
msgstr "Nombre de la Aplicación Web Progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_short_name
|
||||
msgid "Progressive Web App Short Name"
|
||||
msgstr "Nombre Corto de la Aplicación Web Progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Service workers are not supported! Maybe you are not using HTTPS or you work "
|
||||
"in private mode."
|
||||
msgstr ""
|
||||
"¡Los trabajadores de servicios no son compatibles! Quizás no esté usando "
|
||||
"HTTPS o trabaje en modo privado."
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Short Name"
|
||||
msgstr "Nombre Corto"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,help:web_pwa_oca.field_res_config_settings__pwa_short_name
|
||||
msgid "Short Name of the Progressive Web Application"
|
||||
msgstr "Nombre Corto de la Aplicación Web Progresiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_theme_color
|
||||
msgid "Theme Color"
|
||||
msgstr "Color del Tema"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can only upload PNG files bigger than 512x512"
|
||||
msgstr "Puede solo cargar archivos PNG mayores a 512x512"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can only upload SVG or PNG files. Found: %s."
|
||||
msgstr "Solo se pueden Subir archivos SVG o PNG. Se encontró: %s."
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can't upload a file with more than 2 MB."
|
||||
msgstr "No puede cargar un archivo con un peso superior a 2 MB."
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid "[ServiceWorker] Registered:"
|
||||
msgstr "[ServiceWorker] Registrado:"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid "[ServiceWorker] Registration failed: "
|
||||
msgstr "[ServiceWorker] Registro fallido: "
|
||||
|
||||
#~ msgid "You can only upload SVG or PNG files"
|
||||
#~ msgstr "Puede solo cargar archivos SVG o PNG"
|
|
@ -0,0 +1,128 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_pwa_oca
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 13.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2022-02-01 20:33+0000\n"
|
||||
"Last-Translator: Rodrigo Macedo <rmsolucoeseminformatica@protonmail.com>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: pt_BR\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Generator: Weblate 4.3.2\n"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_background_color
|
||||
msgid "Background Color"
|
||||
msgstr "Cor de Fundo"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model,name:web_pwa_oca.model_res_config_settings
|
||||
msgid "Config Settings"
|
||||
msgstr "Definições de Configuração"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_icon
|
||||
msgid "Icon"
|
||||
msgstr "Ícone"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Name"
|
||||
msgstr "Nome"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Name and icon of your PWA"
|
||||
msgstr "Nome e ícone do seu PWA"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,help:web_pwa_oca.field_res_config_settings__pwa_name
|
||||
msgid "Name of the Progressive Web Application"
|
||||
msgstr "Nome da Aplicação Web Progressiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "PWA Title"
|
||||
msgstr "Título PWA"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Progressive Web App"
|
||||
msgstr "App Web Progressivo"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_name
|
||||
msgid "Progressive Web App Name"
|
||||
msgstr "Nome do App Web Progressivo"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_short_name
|
||||
msgid "Progressive Web App Short Name"
|
||||
msgstr "Nome Curto do App Web Progressivo"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Service workers are not supported! Maybe you are not using HTTPS or you work "
|
||||
"in private mode."
|
||||
msgstr ""
|
||||
"Workers de servição não são suportados! Talvez você não esteja utilizando "
|
||||
"HTTPS ou esteja trabalhando em modo privado."
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Short Name"
|
||||
msgstr "Nome Curto"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,help:web_pwa_oca.field_res_config_settings__pwa_short_name
|
||||
msgid "Short Name of the Progressive Web Application"
|
||||
msgstr "Nome Curto da Aplicação Web Progressiva"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_theme_color
|
||||
msgid "Theme Color"
|
||||
msgstr "Cor do Tema"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can only upload PNG files bigger than 512x512"
|
||||
msgstr "Você só pode carregar arquivos PNG até 512x512"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can only upload SVG or PNG files. Found: %s."
|
||||
msgstr "Você só pode fazer upload de arquivos SVG ou PNG. Encontrado: %s."
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can't upload a file with more than 2 MB."
|
||||
msgstr "Você não pode carregar um arquivo maior que 2MB."
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid "[ServiceWorker] Registered:"
|
||||
msgstr "[ServiceWorker] Registrado:"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid "[ServiceWorker] Registration failed: "
|
||||
msgstr "[ServiceWorker] Falha no registro: "
|
||||
|
||||
#~ msgid "You can only upload SVG or PNG files"
|
||||
#~ msgstr "Você só pode carregar arquivos PNG ou SVG"
|
|
@ -0,0 +1,140 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * web_pwa_oca
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "<span class=\"fa fa-lg fa-globe\" title=\"Icon next to name\"/>"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_background_color
|
||||
msgid "Background Color"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model,name:web_pwa_oca.model_res_config_settings
|
||||
msgid "Config Settings"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_icon
|
||||
msgid "Icon"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Name and icon of your PWA"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,help:web_pwa_oca.field_res_config_settings__pwa_name
|
||||
msgid "Name of the Progressive Web Application"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "PWA Title"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Progressive Web App"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_name
|
||||
msgid "Progressive Web App Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_short_name
|
||||
msgid "Progressive Web App Short Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Service workers are not supported! Maybe you are not using HTTPS or you work"
|
||||
" in private mode."
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.res_config_settings_view_form
|
||||
msgid "Short Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,help:web_pwa_oca.field_res_config_settings__pwa_short_name
|
||||
msgid "Short Name of the Progressive Web Application"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: model:ir.model.fields,field_description:web_pwa_oca.field_res_config_settings__pwa_theme_color
|
||||
msgid "Theme Color"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can only upload PNG files bigger than 512x512"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can only upload SVG or PNG files. Found: %s."
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#: code:addons/web_pwa_oca/models/res_config_settings.py:0
|
||||
#, python-format
|
||||
msgid "You can't upload a file with more than 2 MB."
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid "[ServiceWorker] Registered:"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_pwa_oca
|
||||
#. openerp-web
|
||||
#: code:addons/web_pwa_oca/static/src/js/pwa_manager.js:0
|
||||
#, python-format
|
||||
msgid "[ServiceWorker] Registration failed: "
|
||||
msgstr ""
|
|
@ -0,0 +1 @@
|
|||
from . import res_config_settings
|
|
@ -0,0 +1,159 @@
|
|||
# Copyright 2020 Tecnativa - João Marques
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
import base64
|
||||
import io
|
||||
import sys
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from odoo import _, api, exceptions, fields, models
|
||||
from odoo.tools.mimetypes import guess_mimetype
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
_pwa_icon_url_base = "/web_pwa_oca/icon"
|
||||
|
||||
pwa_name = fields.Char(
|
||||
"Progressive Web App Name", help="Name of the Progressive Web Application"
|
||||
)
|
||||
pwa_short_name = fields.Char(
|
||||
"Progressive Web App Short Name",
|
||||
help="Short Name of the Progressive Web Application",
|
||||
)
|
||||
pwa_icon = fields.Binary("Icon", readonly=False)
|
||||
pwa_background_color = fields.Char("Background Color")
|
||||
pwa_theme_color = fields.Char("Theme Color")
|
||||
|
||||
@api.model
|
||||
def get_values(self):
|
||||
config_parameter_obj_sudo = self.env["ir.config_parameter"].sudo()
|
||||
res = super(ResConfigSettings, self).get_values()
|
||||
res["pwa_name"] = config_parameter_obj_sudo.get_param(
|
||||
"pwa.manifest.name", default="Odoo PWA"
|
||||
)
|
||||
res["pwa_short_name"] = config_parameter_obj_sudo.get_param(
|
||||
"pwa.manifest.short_name", default="Odoo"
|
||||
)
|
||||
pwa_icon_ir_attachment = (
|
||||
self.env["ir.attachment"]
|
||||
.sudo()
|
||||
.search([("url", "like", self._pwa_icon_url_base + ".")])
|
||||
)
|
||||
res["pwa_icon"] = (
|
||||
pwa_icon_ir_attachment.datas if pwa_icon_ir_attachment else False
|
||||
)
|
||||
res["pwa_background_color"] = config_parameter_obj_sudo.get_param(
|
||||
"pwa.manifest.background_color", default="#2E69B5"
|
||||
)
|
||||
res["pwa_theme_color"] = config_parameter_obj_sudo.get_param(
|
||||
"pwa.manifest.theme_color", default="#2E69B5"
|
||||
)
|
||||
return res
|
||||
|
||||
def _unpack_icon(self, icon):
|
||||
# Wrap decoded_icon in BytesIO object
|
||||
decoded_icon = base64.b64decode(icon)
|
||||
icon_bytes = io.BytesIO(decoded_icon)
|
||||
return Image.open(icon_bytes)
|
||||
|
||||
def _write_icon_to_attachment(self, extension, mimetype, size=None):
|
||||
url = self._pwa_icon_url_base + extension
|
||||
icon = self.pwa_icon
|
||||
# Resize image
|
||||
if size:
|
||||
image = self._unpack_icon(icon)
|
||||
resized_image = image.resize(size)
|
||||
icon_bytes_output = io.BytesIO()
|
||||
resized_image.save(icon_bytes_output, format=extension.lstrip(".").upper())
|
||||
icon = base64.b64encode(icon_bytes_output.getvalue())
|
||||
url = "{}{}x{}{}".format(
|
||||
self._pwa_icon_url_base,
|
||||
str(size[0]),
|
||||
str(size[1]),
|
||||
extension,
|
||||
)
|
||||
# Retreive existing attachment
|
||||
existing_attachment = (
|
||||
self.env["ir.attachment"].sudo().search([("url", "like", url)])
|
||||
)
|
||||
# Write values to ir_attachment
|
||||
values = {
|
||||
"datas": icon,
|
||||
"db_datas": icon,
|
||||
"url": url,
|
||||
"name": url,
|
||||
"type": "binary",
|
||||
"mimetype": mimetype,
|
||||
}
|
||||
# Rewrite if exists, else create
|
||||
if existing_attachment:
|
||||
existing_attachment.sudo().write(values)
|
||||
else:
|
||||
self.env["ir.attachment"].sudo().create(values)
|
||||
|
||||
@api.model
|
||||
def set_values(self):
|
||||
config_parameter_obj_sudo = self.env["ir.config_parameter"].sudo()
|
||||
res = super(ResConfigSettings, self).set_values()
|
||||
config_parameter_obj_sudo.set_param("pwa.manifest.name", self.pwa_name)
|
||||
config_parameter_obj_sudo.set_param(
|
||||
"pwa.manifest.short_name", self.pwa_short_name
|
||||
)
|
||||
config_parameter_obj_sudo.set_param(
|
||||
"pwa.manifest.background_color", self.pwa_background_color
|
||||
)
|
||||
config_parameter_obj_sudo.set_param(
|
||||
"pwa.manifest.theme_color", self.pwa_theme_color
|
||||
)
|
||||
# Retrieve previous value for pwa_icon from ir_attachment
|
||||
pwa_icon_ir_attachments = (
|
||||
self.env["ir.attachment"]
|
||||
.sudo()
|
||||
.search([("url", "like", self._pwa_icon_url_base)])
|
||||
)
|
||||
# Delete or ignore if no icon provided
|
||||
if not self.pwa_icon:
|
||||
if pwa_icon_ir_attachments:
|
||||
pwa_icon_ir_attachments.unlink()
|
||||
return res
|
||||
# Fail if icon provided is larger than 2mb
|
||||
if sys.getsizeof(self.pwa_icon) > 2196608:
|
||||
raise exceptions.UserError(
|
||||
_("You can't upload a file with more than 2 MB.")
|
||||
)
|
||||
# Confirm if the pwa_icon binary content is an SVG or PNG
|
||||
# and process accordingly
|
||||
decoded_pwa_icon = base64.b64decode(self.pwa_icon)
|
||||
# Full mimetype detection
|
||||
pwa_icon_mimetype = guess_mimetype(decoded_pwa_icon)
|
||||
pwa_icon_extension = "." + pwa_icon_mimetype.split("/")[-1].split("+")[0]
|
||||
if not pwa_icon_mimetype.startswith(
|
||||
"image/svg"
|
||||
) and not pwa_icon_mimetype.startswith("image/png"):
|
||||
raise exceptions.UserError(
|
||||
_("You can only upload SVG or PNG files. Found: %s.")
|
||||
% pwa_icon_mimetype
|
||||
)
|
||||
# Delete all previous records if we are writting new ones
|
||||
if pwa_icon_ir_attachments:
|
||||
pwa_icon_ir_attachments.unlink()
|
||||
self._write_icon_to_attachment(pwa_icon_extension, pwa_icon_mimetype)
|
||||
# write multiple sizes if not SVG
|
||||
if pwa_icon_extension != ".svg":
|
||||
# Fail if provided PNG is smaller than 512x512
|
||||
if self._unpack_icon(self.pwa_icon).size < (512, 512):
|
||||
raise exceptions.UserError(
|
||||
_("You can only upload PNG files bigger than 512x512")
|
||||
)
|
||||
for size in [
|
||||
(128, 128),
|
||||
(144, 144),
|
||||
(152, 152),
|
||||
(192, 192),
|
||||
(256, 256),
|
||||
(512, 512),
|
||||
]:
|
||||
self._write_icon_to_attachment(
|
||||
pwa_icon_extension, pwa_icon_mimetype, size=size
|
||||
)
|
|
@ -0,0 +1,11 @@
|
|||
This module allows you to set the following parameters under settings to customize the appearance of the application
|
||||
|
||||
* PWA Name (defaults to "Odoo PWA")
|
||||
* PWA Short Name (defaults to "Odoo PWA")
|
||||
* PWA Icon (**SVG**) (defaults to "/web_pwa_oca/static/img/icons/odoo-logo.svg")
|
||||
|
||||
To configure your PWA:
|
||||
|
||||
#. Go to **Settings > General Settings > Progressive Web App**.
|
||||
#. Set the parameters (*Note:* Icon **must be a SVG file**)
|
||||
#. **Save**
|
|
@ -0,0 +1,9 @@
|
|||
* `TAKOBI <https://takobi.online>`_:
|
||||
|
||||
* Lorenzo Battistini
|
||||
|
||||
* `Tecnativa <https://tecnativa.com>`_:
|
||||
|
||||
* Alexandre D. Díaz
|
||||
* João Marques
|
||||
* Sergio Teruel
|
|
@ -0,0 +1,16 @@
|
|||
Make Odoo an installable Progressive Web Application.
|
||||
|
||||
Progressive Web Apps provide an installable, app-like experience on desktop and mobile that are built and delivered directly via the web.
|
||||
They're web apps that are fast and reliable. And most importantly, they're web apps that work in any browser.
|
||||
If you're building a web app today, you're already on the path towards building a Progressive Web App.
|
||||
|
||||
|
||||
+ Developers Info.
|
||||
|
||||
The service worker is contructed using 'Odoo Class' to have the same class inheritance behaviour that in the 'user pages'. Be noticed
|
||||
that 'Odoo Bootstrap' is not supported so, you can't use 'require' here.
|
||||
|
||||
All service worker content can be found in 'static/src/js/worker'. The management between 'user pages' and service worker is done in
|
||||
'pwa_manager.js'.
|
||||
|
||||
The purpose of this module is give a base to make PWA applications.
|
|
@ -0,0 +1,18 @@
|
|||
After having installed this module, browsing your odoo on mobile you will be able to install it as a PWA.
|
||||
|
||||
It is strongly recommended to use this module with a responsive layout, like the one provided by web_responsive.
|
||||
|
||||
This module is intended to be used by Odoo back-end users (employees).
|
||||
|
||||
When a Progressive Web App is installed, it looks and behaves like all of the other installed apps.
|
||||
It launches from the same place that other apps launch. It runs in an app without an address bar or other browser UI.
|
||||
And like all other installed apps, it's a top level app in the task switcher.
|
||||
|
||||
In Chrome, a Progressive Web App can either be installed through the three-dot context menu.
|
||||
|
||||
In case you previously installed `web_pwa`, run the following steps with `odoo shell`, after having installed `openupgradelib`:
|
||||
|
||||
|
||||
>>> from openupgradelib import openupgrade
|
||||
>>> openupgrade.update_module_names(env.cr, [('web_pwa', 'web_pwa_oca')], merge_modules=False)
|
||||
>>> env.cr.commit()
|
|
@ -0,0 +1,35 @@
|
|||
* Integrate `Notification API <https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification>`_
|
||||
* Integrate `Web Share API <https://web.dev/web-share/>`_
|
||||
* Create ``portal_pwa`` module, intended to be used by front-end users (customers, suppliers...)
|
||||
* Current *John Resig's inheritance* implementation doesn't support ``async``
|
||||
functions because ``this._super`` can't be called inside a promise. So we
|
||||
need to use the following workaround:
|
||||
|
||||
- Natural 'async/await' example (This breaks "_super" call):
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var MyClass = OdooClass.extend({
|
||||
myFunc: async function() {
|
||||
const mydata = await ...do await stuff...
|
||||
return mydata;
|
||||
}
|
||||
});
|
||||
|
||||
- Same code with the workaround:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var MyClass = OdooClass.extend({
|
||||
myFunc: function() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const mydata = await ...do await stuff...
|
||||
return resolve(mydata);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
* Fix issue when trying to run in localhost with several databases. The browser
|
||||
doesn't send the cookie and web manifest returns 404.
|
||||
* Firefox can't detect 'standalone' mode. See https://bugzilla.mozilla.org/show_bug.cgi?id=1285858
|
||||
* Firefox disable service worker in private mode. See https://bugzilla.mozilla.org/show_bug.cgi?id=1601916
|
|
@ -0,0 +1,7 @@
|
|||
To use your PWA:
|
||||
|
||||
#. Open the Odoo web app using a supported browser (See https://caniuse.com/?search=A2HS)
|
||||
#. Open the browser options
|
||||
#. Click on 'Add to Home screen' (or 'Install' in other browsers)
|
||||
|
||||
** Maybe you need refresh the page to load the service worker after using the option.
|
After Width: | Height: | Size: 16 KiB |
|
@ -0,0 +1,533 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<title>Progressive web application</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="progressive-web-application">
|
||||
<h1 class="title">Progressive web application</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_pwa_oca"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_pwa_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>Make Odoo an installable Progressive Web Application.</p>
|
||||
<p>Progressive Web Apps provide an installable, app-like experience on desktop and mobile that are built and delivered directly via the web.
|
||||
They’re web apps that are fast and reliable. And most importantly, they’re web apps that work in any browser.
|
||||
If you’re building a web app today, you’re already on the path towards building a Progressive Web App.</p>
|
||||
<ul class="simple">
|
||||
<li>Developers Info.</li>
|
||||
</ul>
|
||||
<p>The service worker is contructed using ‘Odoo Class’ to have the same class inheritance behaviour that in the ‘user pages’. Be noticed
|
||||
that ‘Odoo Bootstrap’ is not supported so, you can’t use ‘require’ here.</p>
|
||||
<p>All service worker content can be found in ‘static/src/js/worker’. The management between ‘user pages’ and service worker is done in
|
||||
‘pwa_manager.js’.</p>
|
||||
<p>The purpose of this module is give a base to make PWA applications.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#installation" id="id1">Installation</a></li>
|
||||
<li><a class="reference internal" href="#configuration" id="id2">Configuration</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="id3">Usage</a></li>
|
||||
<li><a class="reference internal" href="#known-issues-roadmap" id="id4">Known issues / Roadmap</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id5">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id6">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id7">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id8">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="installation">
|
||||
<h1><a class="toc-backref" href="#id1">Installation</a></h1>
|
||||
<p>After having installed this module, browsing your odoo on mobile you will be able to install it as a PWA.</p>
|
||||
<p>It is strongly recommended to use this module with a responsive layout, like the one provided by web_responsive.</p>
|
||||
<p>This module is intended to be used by Odoo back-end users (employees).</p>
|
||||
<p>When a Progressive Web App is installed, it looks and behaves like all of the other installed apps.
|
||||
It launches from the same place that other apps launch. It runs in an app without an address bar or other browser UI.
|
||||
And like all other installed apps, it’s a top level app in the task switcher.</p>
|
||||
<p>In Chrome, a Progressive Web App can either be installed through the three-dot context menu.</p>
|
||||
<p>In case you previously installed <cite>web_pwa</cite>, run the following steps with <cite>odoo shell</cite>, after having installed <cite>openupgradelib</cite>:</p>
|
||||
<pre class="doctest-block">
|
||||
>>> from openupgradelib import openupgrade
|
||||
>>> openupgrade.update_module_names(env.cr, [('web_pwa', 'web_pwa_oca')], merge_modules=False)
|
||||
>>> env.cr.commit()
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h1><a class="toc-backref" href="#id2">Configuration</a></h1>
|
||||
<p>This module allows you to set the following parameters under settings to customize the appearance of the application</p>
|
||||
<ul class="simple">
|
||||
<li>PWA Name (defaults to “Odoo PWA”)</li>
|
||||
<li>PWA Short Name (defaults to “Odoo PWA”)</li>
|
||||
<li>PWA Icon (<strong>SVG</strong>) (defaults to “/web_pwa_oca/static/img/icons/odoo-logo.svg”)</li>
|
||||
</ul>
|
||||
<p>To configure your PWA:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Go to <strong>Settings > General Settings > Progressive Web App</strong>.</li>
|
||||
<li>Set the parameters (<em>Note:</em> Icon <strong>must be a SVG file</strong>)</li>
|
||||
<li><strong>Save</strong></li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#id3">Usage</a></h1>
|
||||
<p>To use your PWA:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Open the Odoo web app using a supported browser (See <a class="reference external" href="https://caniuse.com/?search=A2HS">https://caniuse.com/?search=A2HS</a>)</li>
|
||||
<li>Open the browser options</li>
|
||||
<li>Click on ‘Add to Home screen’ (or ‘Install’ in other browsers)</li>
|
||||
</ol>
|
||||
<p>** Maybe you need refresh the page to load the service worker after using the option.</p>
|
||||
</div>
|
||||
<div class="section" id="known-issues-roadmap">
|
||||
<h1><a class="toc-backref" href="#id4">Known issues / Roadmap</a></h1>
|
||||
<ul>
|
||||
<li><p class="first">Integrate <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification">Notification API</a></p>
|
||||
</li>
|
||||
<li><p class="first">Integrate <a class="reference external" href="https://web.dev/web-share/">Web Share API</a></p>
|
||||
</li>
|
||||
<li><p class="first">Create <tt class="docutils literal">portal_pwa</tt> module, intended to be used by front-end users (customers, suppliers…)</p>
|
||||
</li>
|
||||
<li><p class="first">Current <em>John Resig’s inheritance</em> implementation doesn’t support <tt class="docutils literal">async</tt>
|
||||
functions because <tt class="docutils literal">this._super</tt> can’t be called inside a promise. So we
|
||||
need to use the following workaround:</p>
|
||||
<ul>
|
||||
<li><p class="first">Natural ‘async/await’ example (This breaks “_super” call):</p>
|
||||
<pre class="code javascript literal-block">
|
||||
<span class="kd">var</span> <span class="nx">MyClass</span> <span class="o">=</span> <span class="nx">OdooClass</span><span class="p">.</span><span class="nx">extend</span><span class="p">({</span>
|
||||
<span class="nx">myFunc</span><span class="o">:</span> <span class="k">async</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="kd">const</span> <span class="nx">mydata</span> <span class="o">=</span> <span class="k">await</span> <span class="p">...</span><span class="k">do</span> <span class="k">await</span> <span class="nx">stuff</span><span class="p">...</span>
|
||||
<span class="k">return</span> <span class="nx">mydata</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">});</span>
|
||||
</pre>
|
||||
</li>
|
||||
<li><p class="first">Same code with the workaround:</p>
|
||||
<pre class="code javascript literal-block">
|
||||
<span class="kd">var</span> <span class="nx">MyClass</span> <span class="o">=</span> <span class="nx">OdooClass</span><span class="p">.</span><span class="nx">extend</span><span class="p">({</span>
|
||||
<span class="nx">myFunc</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="k">return</span> <span class="ow">new</span> <span class="nb">Promise</span><span class="p">(</span><span class="k">async</span> <span class="p">(</span><span class="nx">resolve</span><span class="p">,</span> <span class="nx">reject</span><span class="p">)</span> <span class="p">=></span> <span class="p">{</span>
|
||||
<span class="kd">const</span> <span class="nx">mydata</span> <span class="o">=</span> <span class="k">await</span> <span class="p">...</span><span class="k">do</span> <span class="k">await</span> <span class="nx">stuff</span><span class="p">...</span>
|
||||
<span class="k">return</span> <span class="nx">resolve</span><span class="p">(</span><span class="nx">mydata</span><span class="p">);</span>
|
||||
<span class="p">});</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">});</span>
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p class="first">Fix issue when trying to run in localhost with several databases. The browser
|
||||
doesn’t send the cookie and web manifest returns 404.</p>
|
||||
</li>
|
||||
<li><p class="first">Firefox can’t detect ‘standalone’ mode. See <a class="reference external" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1285858">https://bugzilla.mozilla.org/show_bug.cgi?id=1285858</a></p>
|
||||
</li>
|
||||
<li><p class="first">Firefox disable service worker in private mode. See <a class="reference external" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1601916">https://bugzilla.mozilla.org/show_bug.cgi?id=1601916</a></p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id5">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_pwa_oca%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#id6">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id7">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>TAKOBI</li>
|
||||
<li>Tecnativa</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id8">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://takobi.online">TAKOBI</a>:<ul>
|
||||
<li>Lorenzo Battistini</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference external" href="https://tecnativa.com">Tecnativa</a>:<ul>
|
||||
<li>Alexandre D. Díaz</li>
|
||||
<li>João Marques</li>
|
||||
<li>Sergio Teruel</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id9">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||
<p><a class="reference external" href="https://github.com/eLBati"><img alt="eLBati" src="https://github.com/eLBati.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_pwa_oca">OCA/web</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 16 KiB |
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg:svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="919"
|
||||
height="495"
|
||||
viewBox="0 0 919 495"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
sodipodi:docname="odoo_logo.svg"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
|
||||
<svg:metadata
|
||||
id="metadata14">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</svg:metadata>
|
||||
<svg:defs
|
||||
id="defs12" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="2488"
|
||||
inkscape:window-height="1025"
|
||||
id="namedview10"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.46245919"
|
||||
inkscape:cx="463.82471"
|
||||
inkscape:cy="247.5"
|
||||
inkscape:window-x="72"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg8" />
|
||||
<svg:g
|
||||
fill="none"
|
||||
id="g6">
|
||||
<svg:path
|
||||
fill="#8F8F8F"
|
||||
d="M695 346c-41.421 0-75-33.579-75-75s33.579-75 75-75 75 33.579 75 75-33.579 75-75 75zm0-31c24.3 0 44-19.7 44-44s-19.7-44-44-44-44 19.7-44 44 19.7 44 44 44zm-157 31c-41.421 0-75-33.579-75-75s33.579-75 75-75 75 33.579 75 75-33.579 75-75 75zm0-31c24.3 0 44-19.7 44-44s-19.7-44-44-44-44 19.7-44 44 19.7 44 44 44zm-82-45c0 41.935-33.592 76-75.009 76C339.575 346 306 312.005 306 270.07c0-41.936 30.5-74.07 74.991-74.07 16.442 0 31.647 3.496 44.007 12.58l.002-43.49c0-8.334 7.27-15.09 15.5-15.09 8.228 0 15.5 6.762 15.5 15.09V270zm-75 45c24.3 0 44-19.7 44-44s-19.7-44-44-44-44 19.7-44 44 19.7 44 44 44z"
|
||||
id="path2" />
|
||||
<svg:path
|
||||
fill="#875A7B"
|
||||
d="M224 346c-41.421 0-75-33.579-75-75s33.579-75 75-75 75 33.579 75 75-33.579 75-75 75zm0-31c24.3 0 44-19.7 44-44s-19.7-44-44-44-44 19.7-44 44 19.7 44 44 44z"
|
||||
id="path4" />
|
||||
</svg:g>
|
||||
<script />
|
||||
<script
|
||||
type="text/javascript" />
|
||||
<script
|
||||
type="text/javascript" />
|
||||
</svg:svg>
|
After Width: | Height: | Size: 2.4 KiB |
|
@ -0,0 +1,81 @@
|
|||
/* Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||
|
||||
odoo.define("web_pwa_oca.PWAManager", function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require("web.core");
|
||||
var config = require("web.config");
|
||||
var Widget = require("web.Widget");
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
/**
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function isPWAStandalone() {
|
||||
return (
|
||||
window.navigator.standalone ||
|
||||
document.referrer.includes("android-app://") ||
|
||||
window.matchMedia("(display-mode: standalone)").matches
|
||||
);
|
||||
}
|
||||
|
||||
if (isPWAStandalone()) {
|
||||
config.device.isMobile = true;
|
||||
}
|
||||
|
||||
var PWAManager = Widget.extend({
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this._isServiceWorkerSupported = "serviceWorker" in navigator;
|
||||
if (!this._isServiceWorkerSupported) {
|
||||
console.error(
|
||||
_t(
|
||||
"Service workers are not supported! Maybe you are not using HTTPS or you work in private mode."
|
||||
)
|
||||
);
|
||||
} else {
|
||||
this._service_worker = navigator.serviceWorker;
|
||||
this.registerServiceWorker("/service-worker.js", {
|
||||
updateViaCache: "none",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} sw_script
|
||||
* @returns {Promise}
|
||||
*/
|
||||
registerServiceWorker: function (sw_script, options) {
|
||||
return this._service_worker
|
||||
.register(sw_script, options)
|
||||
.then(this._onRegisterServiceWorker.bind(this))
|
||||
.catch(function (error) {
|
||||
console.log(_t("[ServiceWorker] Registration failed: "), error);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isPWAStandalone: function () {
|
||||
return isPWAStandalone();
|
||||
},
|
||||
|
||||
/**
|
||||
* Need register some extra API? override this!
|
||||
*
|
||||
* @private
|
||||
* @param {ServiceWorkerRegistration} registration
|
||||
*/
|
||||
_onRegisterServiceWorker: function (registration) {
|
||||
console.log(_t("[ServiceWorker] Registered:"), registration);
|
||||
},
|
||||
});
|
||||
|
||||
return PWAManager;
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
/* Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||
/* Copyright 2022 Tecnativa - Sergio Teruel
|
||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||
|
||||
odoo.define("web_pwa_oca.pwa_launch", function (require) {
|
||||
"use strict";
|
||||
var core = require("web.core");
|
||||
var PWAManager = require("web_pwa_oca.PWAManager");
|
||||
|
||||
core.bus.on("web_client_ready", null, function () {
|
||||
this.pwa_manager = new PWAManager(this);
|
||||
const def = this.pwa_manager.start();
|
||||
return Promise.all([def]);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,62 @@
|
|||
/* Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||
|
||||
// Compatibility layer to load some Odoo modules
|
||||
// This is a hack, not a complete implementation!
|
||||
// only expected to be used by boot.js
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
function JQuery(selector, context) {
|
||||
return new JQuery.prototype.init(selector, context);
|
||||
}
|
||||
|
||||
JQuery.prototype = {
|
||||
init: function (selector) {
|
||||
if (typeof selector === "function") {
|
||||
selector();
|
||||
}
|
||||
},
|
||||
|
||||
deparam: function (data) {
|
||||
const params = data.split(",");
|
||||
const res = [];
|
||||
for (const param of params) {
|
||||
res.push(param.split("="));
|
||||
}
|
||||
return _.object(res);
|
||||
},
|
||||
|
||||
param: {
|
||||
querystring: function () {
|
||||
return "debug=1";
|
||||
},
|
||||
},
|
||||
|
||||
when: function (tasks) {
|
||||
return Promise.all(tasks instanceof Array ? tasks : [tasks]).then(
|
||||
(results) => {
|
||||
return results.length === 1 ? results[0] : results;
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
class Deferred {
|
||||
constructor() {
|
||||
this.promise = new Promise((resolve, reject) => {
|
||||
this.reject = reject;
|
||||
this.resolve = resolve;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
JQuery.prototype.Deferred = () => new Deferred();
|
||||
|
||||
self.$ = JQuery;
|
||||
self.$.deparam = JQuery.prototype.deparam;
|
||||
self.$.param = JQuery.prototype.param;
|
||||
self.$.Deferred = JQuery.prototype.Deferred;
|
||||
self.$.when = JQuery.prototype.when;
|
||||
self.window = self;
|
||||
})();
|
|
@ -0,0 +1,57 @@
|
|||
/* Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||
|
||||
/**
|
||||
* Services workers are a piece of software separated from the user page.
|
||||
* Here can't use 'Odoo Bootstrap', so we can't work with 'require' system.
|
||||
* When the service worker is called to be installed from the "pwa_manager"
|
||||
* this class is instantiated.
|
||||
*/
|
||||
|
||||
odoo.define("web_pwa_oca.PWA", function (require) {
|
||||
"use strict";
|
||||
|
||||
const OdooClass = require("web.Class");
|
||||
|
||||
const PWA = OdooClass.extend({
|
||||
// eslint-disable-next-line
|
||||
init: function (params) {
|
||||
// To be overridden
|
||||
this._sw_version = params.sw_version;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {Promise}
|
||||
*/
|
||||
start: function () {
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {Promise}
|
||||
*/
|
||||
installWorker: function () {
|
||||
// To be overridden
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {Promise}
|
||||
*/
|
||||
/* eslint-disable no-unused-vars */
|
||||
activateWorker: function (forced) {
|
||||
// To be overridden
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {Promise}
|
||||
*/
|
||||
processRequest: function (request) {
|
||||
// To be overridden
|
||||
return fetch(request);
|
||||
},
|
||||
});
|
||||
|
||||
return PWA;
|
||||
});
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<template
|
||||
id="web_layout_pwa"
|
||||
name="Web layout PWA"
|
||||
inherit_id="web.webclient_bootstrap"
|
||||
>
|
||||
<xpath expr="//t[@t-call-assets='web.assets_common']" position="before">
|
||||
<!-- Add link rel manifest -->
|
||||
<link rel="manifest" t-attf-href="/web_pwa_oca/manifest.webmanifest" />
|
||||
<!-- Add iOS meta tags and icons -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||
<t
|
||||
t-set="pwa_name"
|
||||
t-value="request.env['ir.config_parameter'].sudo().get_param('pwa.manifest.name')"
|
||||
/>
|
||||
<meta name="apple-mobile-web-app-title" t-att-content="pwa_name" />
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
href="/web_pwa_oca/static/img/icons/icon-152x152.png"
|
||||
/>
|
||||
<!-- Add meta theme-color -->
|
||||
<t
|
||||
t-set="pwa_theme_color"
|
||||
t-value="request.env['ir.config_parameter'].sudo().get_param('pwa.manifest.theme_color')"
|
||||
/>
|
||||
<meta name="theme-color" t-att-content="pwa_theme_color" />
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
|
@ -0,0 +1 @@
|
|||
from . import test_web_pwa_oca_controller
|
|
@ -0,0 +1,124 @@
|
|||
# Copyright 2020 João Marques
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
import base64
|
||||
import json
|
||||
|
||||
import odoo.tests
|
||||
from odoo import exceptions
|
||||
from odoo.modules.module import get_resource_path
|
||||
|
||||
|
||||
class TestUi(odoo.tests.HttpCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.user = self.env.ref("base.user_admin")
|
||||
self.res_config_settings_obj = (
|
||||
self.env["res.config.settings"].with_user(self.user).create({})
|
||||
)
|
||||
|
||||
def test_manifest_valid_json(self):
|
||||
# Call the manifest controller
|
||||
manifest_data = self.url_open("/web_pwa_oca/manifest.webmanifest")
|
||||
# should be valid json
|
||||
manifest_content_str = manifest_data.content.decode("utf-8")
|
||||
json.loads(manifest_content_str)
|
||||
|
||||
def test_manifest_correct_paramenters(self):
|
||||
# Set PWA parameters in settings
|
||||
self.res_config_settings_obj.pwa_name = "Test PWA"
|
||||
self.res_config_settings_obj.pwa_short_name = "Test"
|
||||
# icon should remain the default one
|
||||
self.res_config_settings_obj.pwa_icon = False
|
||||
self.res_config_settings_obj.set_values()
|
||||
|
||||
# Call the manifest controller
|
||||
manifest_data = self.url_open("/web_pwa_oca/manifest.webmanifest")
|
||||
manifest_content_str = manifest_data.content.decode("utf-8")
|
||||
manifest_content = json.loads(manifest_content_str)
|
||||
|
||||
self.assertEqual(manifest_content["name"], "Test PWA")
|
||||
self.assertEqual(manifest_content["short_name"], "Test")
|
||||
# icon should remain the default one
|
||||
self.assertEqual(
|
||||
manifest_content["icons"][0]["src"],
|
||||
"/web_pwa_oca/static/img/icons/icon-128x128.png",
|
||||
)
|
||||
self.assertEqual(manifest_content["icons"][0]["sizes"], "128x128")
|
||||
self.assertTrue(manifest_content["icons"][0]["type"].startswith("image/png"))
|
||||
|
||||
def test_manifest_logo_upload(self):
|
||||
with open(
|
||||
"%s/static/img/icons/odoo_logo.svg" % get_resource_path("web_pwa_oca"), "rb"
|
||||
) as fi:
|
||||
icon_to_send = base64.b64encode(fi.read())
|
||||
|
||||
# Set PWA icon in settings
|
||||
self.res_config_settings_obj.pwa_icon = icon_to_send
|
||||
self.res_config_settings_obj.set_values()
|
||||
|
||||
# Call the manifest controller
|
||||
manifest_data = self.url_open("/web_pwa_oca/manifest.webmanifest")
|
||||
manifest_content_str = manifest_data.content.decode("utf-8")
|
||||
manifest_content = json.loads(manifest_content_str)
|
||||
|
||||
self.assertEqual(manifest_content["icons"][0]["src"], "/web_pwa_oca/icon.svg")
|
||||
self.assertTrue(manifest_content["icons"][0]["type"].startswith("image/svg"))
|
||||
self.assertEqual(
|
||||
manifest_content["icons"][0]["sizes"],
|
||||
"128x128 144x144 152x152 192x192 256x256 512x512",
|
||||
)
|
||||
|
||||
# Get the icon and compare it
|
||||
icon_data = self.url_open("/web_pwa_oca/icon.svg")
|
||||
icon_data_bytes = base64.b64encode(icon_data.content)
|
||||
self.assertEqual(icon_data_bytes, icon_to_send)
|
||||
|
||||
def test_png_logo_upload(self):
|
||||
with open(
|
||||
"%s/static/img/icons/icon-512x512.png" % get_resource_path("web_pwa_oca"),
|
||||
"rb",
|
||||
) as fi:
|
||||
icon_to_send = base64.b64encode(fi.read())
|
||||
|
||||
# Set PWA icon in settings
|
||||
self.res_config_settings_obj.pwa_icon = icon_to_send
|
||||
self.res_config_settings_obj.set_values()
|
||||
|
||||
# Call the manifest controller
|
||||
manifest_data = self.url_open("/web_pwa_oca/manifest.webmanifest")
|
||||
manifest_content_str = manifest_data.content.decode("utf-8")
|
||||
manifest_content = json.loads(manifest_content_str)
|
||||
|
||||
expected_vals = {
|
||||
"src": "/web_pwa_oca/icon512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
}
|
||||
self.assertTrue(expected_vals in manifest_content["icons"])
|
||||
|
||||
def test_manifest_logo_upload_big(self):
|
||||
# Set PWA icon in settings
|
||||
with self.assertRaises(exceptions.UserError):
|
||||
# Image with more than 2MB
|
||||
self.res_config_settings_obj.pwa_icon = b"a" * 3000000
|
||||
self.res_config_settings_obj.set_values()
|
||||
|
||||
def test_manifest_logo_upload_extension(self):
|
||||
with self.assertRaises(exceptions.UserError):
|
||||
# Image that is not SVG or PNG
|
||||
self.res_config_settings_obj.pwa_icon = b"a" * 1000
|
||||
self.res_config_settings_obj.set_values()
|
||||
|
||||
def test_manifest_logo_upload_small(self):
|
||||
icon_to_send = None
|
||||
with open(
|
||||
"%s/static/img/icons/icon-128x128.png" % get_resource_path("web_pwa_oca"),
|
||||
"rb",
|
||||
) as fi:
|
||||
icon_to_send = base64.b64encode(fi.read())
|
||||
# Set PWA icon in settings
|
||||
with self.assertRaises(exceptions.UserError):
|
||||
# Image smaller than 512X512
|
||||
self.res_config_settings_obj.pwa_icon = icon_to_send
|
||||
self.res_config_settings_obj.set_values()
|
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.pwa</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="base_setup.res_config_settings_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<div id="emails" position='after'>
|
||||
<h2>Progressive Web App</h2>
|
||||
<div class="row mt16 o_settings_container" id="pwa_settings">
|
||||
<div class="col-12 col-lg-6 o_setting_box" id="domain_setting">
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="pwa_name" string="PWA Title" />
|
||||
<span
|
||||
class="fa fa-lg fa-globe"
|
||||
title="Icon next to name"
|
||||
/>
|
||||
<div class="text-muted">
|
||||
Name and icon of your PWA
|
||||
</div>
|
||||
<div class="content-group">
|
||||
<div class="row mt16">
|
||||
<label
|
||||
class="col-lg-3 o_light_label"
|
||||
string="Name"
|
||||
for="pwa_name"
|
||||
/>
|
||||
<field name="pwa_name" />
|
||||
</div>
|
||||
<div class="row mt16">
|
||||
<label
|
||||
class="col-lg-3 o_light_label"
|
||||
string="Short Name"
|
||||
for="pwa_short_name"
|
||||
/>
|
||||
<field name="pwa_short_name" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label
|
||||
class="col-lg-3 o_light_label"
|
||||
for="pwa_background_color"
|
||||
/>
|
||||
<field name="pwa_background_color" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label
|
||||
class="col-lg-3 o_light_label"
|
||||
for="pwa_theme_color"
|
||||
/>
|
||||
<field name="pwa_theme_color" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label
|
||||
class="col-lg-3 o_light_label"
|
||||
for="pwa_icon"
|
||||
/>
|
||||
<field
|
||||
name="pwa_icon"
|
||||
widget="image"
|
||||
class="float-left oe_avatar"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|