From 6171f34c6cf779433f0bef8c3b2192b800525500 Mon Sep 17 00:00:00 2001
From: sergio-teruel
Date: Mon, 3 Oct 2022 21:29:56 +0200
Subject: [PATCH] [MIG] web_pwa_oca: Migration to v15.0
---
setup/web_pwa_oca/odoo/addons/web_pwa_oca | 1 +
setup/web_pwa_oca/setup.py | 6 +++
web_pwa_oca/README.rst | 11 ++--
web_pwa_oca/__manifest__.py | 8 ++-
web_pwa_oca/controllers/main.py | 7 +--
web_pwa_oca/controllers/service_worker.py | 10 +++-
web_pwa_oca/readme/CONTRIBUTORS.rst | 1 +
web_pwa_oca/static/description/index.html | 9 ++--
web_pwa_oca/static/src/js/pwa_manager.js | 39 ++++++++++++---
web_pwa_oca/static/src/js/webclient.js | 18 +++----
web_pwa_oca/static/src/js/worker/pwa.js | 19 ++++++-
web_pwa_oca/templates/assets.xml | 17 +------
.../views/res_config_settings_views.xml | 50 +++++++++----------
13 files changed, 121 insertions(+), 75 deletions(-)
create mode 120000 setup/web_pwa_oca/odoo/addons/web_pwa_oca
create mode 100644 setup/web_pwa_oca/setup.py
diff --git a/setup/web_pwa_oca/odoo/addons/web_pwa_oca b/setup/web_pwa_oca/odoo/addons/web_pwa_oca
new file mode 120000
index 000000000..1b7095260
--- /dev/null
+++ b/setup/web_pwa_oca/odoo/addons/web_pwa_oca
@@ -0,0 +1 @@
+../../../../web_pwa_oca
\ No newline at end of file
diff --git a/setup/web_pwa_oca/setup.py b/setup/web_pwa_oca/setup.py
new file mode 100644
index 000000000..28c57bb64
--- /dev/null
+++ b/setup/web_pwa_oca/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+ setup_requires=['setuptools-odoo'],
+ odoo_addon=True,
+)
diff --git a/web_pwa_oca/README.rst b/web_pwa_oca/README.rst
index e92ab481c..86d33d74a 100644
--- a/web_pwa_oca/README.rst
+++ b/web_pwa_oca/README.rst
@@ -14,13 +14,13 @@ Progressive web application
: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/14.0/web_pwa_oca
+ :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-14-0/web-14-0-web_pwa_oca
+ :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/14.0
+ :target: https://runbot.odoo-community.org/runbot/162/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -140,7 +140,7 @@ Bug Tracker
Bugs are tracked on `GitHub 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -164,6 +164,7 @@ Contributors
* Alexandre D. Díaz
* João Marques
+ * Sergio Teruel
Maintainers
~~~~~~~~~~~
@@ -186,6 +187,6 @@ Current `maintainer `__:
|maintainer-eLBati|
-This module is part of the `OCA/web `_ project on GitHub.
+This module is part of the `OCA/web `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/web_pwa_oca/__manifest__.py b/web_pwa_oca/__manifest__.py
index 9bae0c3cb..5cd68293a 100644
--- a/web_pwa_oca/__manifest__.py
+++ b/web_pwa_oca/__manifest__.py
@@ -6,7 +6,7 @@
{
"name": "Progressive web application",
"summary": "Make Odoo a PWA",
- "version": "14.0.1.0.0",
+ "version": "15.0.1.0.0",
"development_status": "Beta",
"category": "Website",
"website": "https://github.com/OCA/web",
@@ -17,5 +17,11 @@
"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"],
}
diff --git a/web_pwa_oca/controllers/main.py b/web_pwa_oca/controllers/main.py
index fdaad56c1..bb3250e24 100644
--- a/web_pwa_oca/controllers/main.py
+++ b/web_pwa_oca/controllers/main.py
@@ -13,9 +13,9 @@ class PWA(Controller):
return [
"/web/static/lib/underscore/underscore.js",
"/web_pwa_oca/static/src/js/worker/jquery-sw-compat.js",
- "/web/static/src/js/promise_extension.js",
- "/web/static/src/js/boot.js",
- "/web/static/src/js/core/class.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",
]
@@ -52,6 +52,7 @@ class PWA(Controller):
% (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"):
diff --git a/web_pwa_oca/controllers/service_worker.py b/web_pwa_oca/controllers/service_worker.py
index ffd8fd737..1ec3e6e38 100644
--- a/web_pwa_oca/controllers/service_worker.py
+++ b/web_pwa_oca/controllers/service_worker.py
@@ -48,7 +48,15 @@ class ServiceWorker(PWA):
def _get_js_pwa_init(self):
return """
- const oca_pwa = new PWA({});
+ 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()
)
diff --git a/web_pwa_oca/readme/CONTRIBUTORS.rst b/web_pwa_oca/readme/CONTRIBUTORS.rst
index 200dad8dc..1484b47b2 100644
--- a/web_pwa_oca/readme/CONTRIBUTORS.rst
+++ b/web_pwa_oca/readme/CONTRIBUTORS.rst
@@ -6,3 +6,4 @@
* Alexandre D. Díaz
* João Marques
+ * Sergio Teruel
diff --git a/web_pwa_oca/static/description/index.html b/web_pwa_oca/static/description/index.html
index 3c697997a..7f8ff10b0 100644
--- a/web_pwa_oca/static/description/index.html
+++ b/web_pwa_oca/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
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.
@@ -464,7 +464,7 @@ need to use the following workaround:
varMyClass=OdooClass.extend({myFunc:function(){
- returnnewPromise(async(resolve,reject)=>{
+ returnnewPromise(async(resolve,reject)=>{constmydata=await...doawaitstuff...returnresolve(mydata);});
@@ -488,7 +488,7 @@ doesn’t send the cookie and web manifest returns 404.
Bugs are tracked on GitHub 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.