3
0
Fork 0

Rename web_pwa -> web_pwa_oca

15.0-ocabot-merge-pr-2789-by-pedrobaeza-bump-patch
eLBati 2020-06-05 08:12:22 +02:00 committed by sergio-teruel
parent 7d9053cb69
commit 4ec8d1ab8b
23 changed files with 1074 additions and 0 deletions

View File

@ -0,0 +1,134 @@
===========================
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/12.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-12-0/web-12-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/12.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.
**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.
This module also provides a "Install PWA" link in Odoo user 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
=============
The following system parameters con be set to customize the appearance of the application
* pwa.manifest.name (defaults to "Odoo PWA")
* pwa.manifest.short_name (defaults to "Odoo PWA")
* pwa.manifest.icon128x128 (defaults to "/web_pwa_oca/static/img/icons/icon-128x128.png")
* pwa.manifest.icon144x144 (defaults to "/web_pwa_oca/static/img/icons/icon-144x144.png")
* pwa.manifest.icon152x152 (defaults to "/web_pwa_oca/static/img/icons/icon-152x152.png")
* pwa.manifest.icon192x192 (defaults to "/web_pwa_oca/static/img/icons/icon-192x192.png")
* pwa.manifest.icon256x256 (defaults to "/web_pwa_oca/static/img/icons/icon-256x256.png")
* pwa.manifest.icon512x512 (defaults to "/web_pwa_oca/static/img/icons/icon-512x512.png")
Known issues / Roadmap
======================
* Evaluate to extend ``FILES_TO_CACHE``
* Evaluate to use a normal JS file for service worker and download data from a normal JSON controller
* 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...)
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:%2012.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
Contributors
~~~~~~~~~~~~
* `TAKOBI <https://takobi.online>`_:
* Lorenzo Battistini
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/12.0/web_pwa_oca>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -0,0 +1 @@
from . import controllers

View File

@ -0,0 +1,27 @@
# Copyright 2020 Lorenzo Battistini @ TAKOBI
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "Progressive web application",
"summary": "Make Odoo a PWA",
"version": "12.0.1.0.0",
"development_status": "Beta",
"category": "Website",
"website": "https://github.com/OCA/web",
"author": "TAKOBI, Odoo Community Association (OCA)",
"maintainers": ["eLBati"],
"license": "LGPL-3",
"application": True,
"installable": True,
"depends": [
'web',
'mail',
],
"data": [
"views/webclient_templates.xml",
],
'qweb': [
'static/src/xml/pwa_install.xml',
],
'images': ['static/description/pwa.png'],
}

View File

@ -0,0 +1 @@
from . import main

View File

@ -0,0 +1,75 @@
from odoo.http import request, Controller, route
class PWA(Controller):
def get_asset_urls(self, asset_xml_id):
qweb = request.env['ir.qweb'].sudo()
assets = qweb._get_asset_nodes(asset_xml_id, {}, True, True)
urls = []
for asset in assets:
if asset[0] == 'link':
urls.append(asset[1]['href'])
if asset[0] == 'script':
urls.append(asset[1]['src'])
return urls
@route('/service-worker.js', type='http', auth="public")
def service_worker(self):
qweb = request.env['ir.qweb'].sudo()
urls = []
urls.extend(self.get_asset_urls("web.assets_common"))
urls.extend(self.get_asset_urls("web.assets_backend"))
version_list = []
for url in urls:
version_list.append(url.split('/')[3])
cache_version = '-'.join(version_list)
mimetype = 'text/javascript;charset=utf-8'
content = qweb.render('web_pwa_oca.service_worker', {
'pwa_cache_name': cache_version,
'pwa_files_to_cache': urls,
})
return request.make_response(content, [('Content-Type', mimetype)])
@route('/web_pwa_oca/manifest.json', type='http', auth="public")
def manifest(self):
qweb = request.env['ir.qweb'].sudo()
config_param = request.env['ir.config_parameter'].sudo()
pwa_name = config_param.get_param("pwa.manifest.name", "Odoo PWA")
pwa_short_name = config_param.get_param("pwa.manifest.short_name", "Odoo PWA")
icon128x128 = config_param.get_param(
"pwa.manifest.icon128x128",
"/web_pwa_oca/static/img/icons/icon-128x128.png")
icon144x144 = config_param.get_param(
"pwa.manifest.icon144x144",
"/web_pwa_oca/static/img/icons/icon-144x144.png")
icon152x152 = config_param.get_param(
"pwa.manifest.icon152x152",
"/web_pwa_oca/static/img/icons/icon-152x152.png")
icon192x192 = config_param.get_param(
"pwa.manifest.icon192x192",
"/web_pwa_oca/static/img/icons/icon-192x192.png")
icon256x256 = config_param.get_param(
"pwa.manifest.icon256x256",
"/web_pwa_oca/static/img/icons/icon-256x256.png")
icon512x512 = config_param.get_param(
"pwa.manifest.icon512x512",
"/web_pwa_oca/static/img/icons/icon-512x512.png")
background_color = config_param.get_param(
"pwa.manifest.background_color", "#2E69B5")
theme_color = config_param.get_param(
"pwa.manifest.theme_color", "#2E69B5")
mimetype = 'application/json;charset=utf-8'
content = qweb.render('web_pwa_oca.manifest', {
'pwa_name': pwa_name,
'pwa_short_name': pwa_short_name,
'icon128x128': icon128x128,
'icon144x144': icon144x144,
'icon152x152': icon152x152,
'icon192x192': icon192x192,
'icon256x256': icon256x256,
'icon512x512': icon512x512,
'background_color': background_color,
'theme_color': theme_color,
})
return request.make_response(content, [('Content-Type', mimetype)])

View File

@ -0,0 +1,158 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_pwa_oca
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.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.manifest
msgid "\",\n"
" \"sizes\": \"128x128\",\n"
" \"type\": \"image/png\"\n"
" }, {\n"
" \"src\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "\",\n"
" \"sizes\": \"144x144\",\n"
" \"type\": \"image/png\"\n"
" }, {\n"
" \"src\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "\",\n"
" \"sizes\": \"152x152\",\n"
" \"type\": \"image/png\"\n"
" }, {\n"
" \"src\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "\",\n"
" \"sizes\": \"192x192\",\n"
" \"type\": \"image/png\"\n"
" }, {\n"
" \"src\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "\",\n"
" \"sizes\": \"256x256\",\n"
" \"type\": \"image/png\"\n"
" }, {\n"
" \"src\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "\",\n"
" \"sizes\": \"512x512\",\n"
" \"type\": \"image/png\"\n"
" }],\n"
" \"start_url\": \"/web\",\n"
" \"display\": \"standalone\",\n"
" \"background_color\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "\",\n"
" \"icons\": [{\n"
" \"src\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "\",\n"
" \"short_name\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "\",\n"
" \"theme_color\": \""
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.service_worker
msgid "';\n"
"const FILES_TO_CACHE = ["
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.service_worker
msgid "'use strict';\n"
"const CACHE_NAME = '"
msgstr ""
#. module: web_pwa_oca
#. openerp-web
#: code:addons/web_pwa_oca/static/src/xml/pwa_install.xml:5
#, python-format
msgid "Install PWA"
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.service_worker
msgid "];\n"
"self.addEventListener('install', function (evt) {\n"
" console.log('[ServiceWorker] Install');\n"
" evt.waitUntil(\n"
" caches.open(CACHE_NAME).then(function (cache) {\n"
" console.log('[ServiceWorker] Pre-caching offline page');\n"
" return cache.addAll(FILES_TO_CACHE);\n"
" })\n"
" );\n"
" self.skipWaiting();\n"
"});\n"
"self.addEventListener('activate', function(evt) {\n"
" console.log('[ServiceWorker] Activate');\n"
" evt.waitUntil(\n"
" caches.keys().then(function(keyList) {\n"
" return Promise.all(keyList.map(function(key) {\n"
" if (key !== CACHE_NAME) {\n"
" console.log('[ServiceWorker] Removing old cache', key);\n"
" return caches.delete(key);\n"
" }\n"
" }));\n"
" })\n"
" );\n"
" self.clients.claim();\n"
"});\n"
"self.addEventListener('fetch', function(evt) {\n"
" if (evt.request.cache === 'only-if-cached' &amp;&amp; evt.request.mode !== 'same-origin') {\n"
" return;\n"
" }\n"
" console.log('[ServiceWorker] Fetch', evt.request.url);\n"
" evt.respondWith(\n"
" caches.open(CACHE_NAME).then(function(cache) {\n"
" return cache.match(evt.request)\n"
" .then(function(response) {\n"
" return response || fetch(evt.request);\n"
" });\n"
" })\n"
" );\n"
"});"
msgstr ""
#. module: web_pwa_oca
#: model_terms:ir.ui.view,arch_db:web_pwa_oca.manifest
msgid "{\n"
" \"name\": \""
msgstr ""

View File

@ -0,0 +1,10 @@
The following system parameters con be set to customize the appearance of the application
* pwa.manifest.name (defaults to "Odoo PWA")
* pwa.manifest.short_name (defaults to "Odoo PWA")
* pwa.manifest.icon128x128 (defaults to "/web_pwa_oca/static/img/icons/icon-128x128.png")
* pwa.manifest.icon144x144 (defaults to "/web_pwa_oca/static/img/icons/icon-144x144.png")
* pwa.manifest.icon152x152 (defaults to "/web_pwa_oca/static/img/icons/icon-152x152.png")
* pwa.manifest.icon192x192 (defaults to "/web_pwa_oca/static/img/icons/icon-192x192.png")
* pwa.manifest.icon256x256 (defaults to "/web_pwa_oca/static/img/icons/icon-256x256.png")
* pwa.manifest.icon512x512 (defaults to "/web_pwa_oca/static/img/icons/icon-512x512.png")

View File

@ -0,0 +1,3 @@
* `TAKOBI <https://takobi.online>`_:
* Lorenzo Battistini

View File

@ -0,0 +1,5 @@
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.

View File

@ -0,0 +1,20 @@
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.
This module also provides a "Install PWA" link in Odoo user 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()

View File

@ -0,0 +1,5 @@
* Evaluate to extend ``FILES_TO_CACHE``
* Evaluate to use a normal JS file for service worker and download data from a normal JSON controller
* 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...)

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,471 @@
<?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/12.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-12-0/web-12-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/12.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.
Theyre web apps that are fast and reliable. And most importantly, theyre web apps that work in any browser.
If youre building a web app today, youre already on the path towards building a Progressive Web App.</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="#known-issues-roadmap" id="id3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">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, its 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>This module also provides a “Install PWA” link in Odoo user 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">
&gt;&gt;&gt; from openupgradelib import openupgrade
&gt;&gt;&gt; openupgrade.update_module_names(env.cr, [('web_pwa', 'web_pwa_oca')], merge_modules=False)
&gt;&gt;&gt; env.cr.commit()
</pre>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id2">Configuration</a></h1>
<p>The following system parameters con be set to customize the appearance of the application</p>
<ul class="simple">
<li>pwa.manifest.name (defaults to “Odoo PWA”)</li>
<li>pwa.manifest.short_name (defaults to “Odoo PWA”)</li>
<li>pwa.manifest.icon128x128 (defaults to “/web_pwa_oca/static/img/icons/icon-128x128.png”)</li>
<li>pwa.manifest.icon144x144 (defaults to “/web_pwa_oca/static/img/icons/icon-144x144.png”)</li>
<li>pwa.manifest.icon152x152 (defaults to “/web_pwa_oca/static/img/icons/icon-152x152.png”)</li>
<li>pwa.manifest.icon192x192 (defaults to “/web_pwa_oca/static/img/icons/icon-192x192.png”)</li>
<li>pwa.manifest.icon256x256 (defaults to “/web_pwa_oca/static/img/icons/icon-256x256.png”)</li>
<li>pwa.manifest.icon512x512 (defaults to “/web_pwa_oca/static/img/icons/icon-512x512.png”)</li>
</ul>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Evaluate to extend <tt class="docutils literal">FILES_TO_CACHE</tt></li>
<li>Evaluate to use a normal JS file for service worker and download data from a normal JSON controller</li>
<li>Integrate <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification">Notification API</a></li>
<li>Integrate <a class="reference external" href="https://web.dev/web-share/">Web Share API</a></li>
<li>Create <tt class="docutils literal">portal_pwa</tt> module, intended to be used by front-end users (customers, suppliers…)</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id4">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:%2012.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="#id5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id6">Authors</a></h2>
<ul class="simple">
<li>TAKOBI</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id7">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://takobi.online">TAKOBI</a>:<ul>
<li>Lorenzo Battistini</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id8">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/12.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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,45 @@
odoo.define('web_pwa_oca.systray.install', function (require) {
"use strict";
var core = require('web.core');
var session = require('web.session');
var UserMenu = require('web.UserMenu');
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('/service-worker.js')
.then(function (reg) {
console.log('Service worker registered.', reg);
});
});
}
var deferredInstallPrompt = null;
UserMenu.include({
start: function () {
window.addEventListener('beforeinstallprompt', this.saveBeforeInstallPromptEvent);
return this._super.apply(this, arguments);
},
saveBeforeInstallPromptEvent: function(evt) {
deferredInstallPrompt = evt;
this.$.find('#pwa_install_button')[0].removeAttribute('hidden');
},
_onMenuInstallpwa: function () {
deferredInstallPrompt.prompt();
// Hide the install button, it can't be called twice.
this.el.setAttribute('hidden', true);
// Log user response to prompt.
deferredInstallPrompt.userChoice
.then(function (choice) {
if (choice.outcome === 'accepted') {
console.log('User accepted the A2HS prompt', choice);
} else {
console.log('User dismissed the A2HS prompt', choice);
}
deferredInstallPrompt = null;
});
},
});
});

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="web_pwa_oca.systray.install">
<a href="#" role="menuitem" id="pwa_install_button" data-menu="installpwa" class="dropdown-item" hidden="1">Install PWA</a>
</t>
<t t-extend="UserMenu.Actions">
<t t-jquery="a[data-menu='settings']" t-operation="after">
<t t-call="web_pwa_oca.systray.install"/>
</t>
</t>
</templates>

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="web_layout_pwa" name="Web layout PWA" inherit_id="web.layout">
<xpath expr="//meta[@name='viewport']" position="after">
<!-- Add link rel manifest -->
<link rel="manifest" href="/web_pwa_oca/manifest.json"/>
<!-- 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"/>
<meta name="apple-mobile-web-app-title" content="Odoo PWA"/>
<link rel="apple-touch-icon" href="/web_pwa_oca/static/img/icons/icon-152x152.png"/>
<!-- Add meta theme-color -->
<meta name="theme-color" content="#2E69B5" />
</xpath>
</template>
<template id="assets_backend" name="PWA assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_pwa_oca/static/src/js/pwa_install.js"/>
</xpath>
</template>
<template id="service_worker" name="PWA service worker">
'use strict';
const CACHE_NAME = '<t t-esc="pwa_cache_name"/>';
const FILES_TO_CACHE = [
<t t-foreach="pwa_files_to_cache" t-as="file_to_cache">
'<t t-esc="file_to_cache"/>',
</t>
];
self.addEventListener('install', function (evt) {
console.log('[ServiceWorker] Install');
evt.waitUntil(
caches.open(CACHE_NAME).then(function (cache) {
console.log('[ServiceWorker] Pre-caching offline page');
return cache.addAll(FILES_TO_CACHE);
})
);
self.skipWaiting();
});
self.addEventListener('activate', function(evt) {
console.log('[ServiceWorker] Activate');
evt.waitUntil(
caches.keys().then(function(keyList) {
return Promise.all(keyList.map(function(key) {
if (key !== CACHE_NAME) {
console.log('[ServiceWorker] Removing old cache', key);
return caches.delete(key);
}
}));
})
);
self.clients.claim();
});
self.addEventListener('fetch', function(evt) {
if (evt.request.cache === 'only-if-cached' &amp;&amp; evt.request.mode !== 'same-origin') {
return;
}
console.log('[ServiceWorker] Fetch', evt.request.url);
evt.respondWith(
caches.open(CACHE_NAME).then(function(cache) {
return cache.match(evt.request)
.then(function(response) {
return response || fetch(evt.request);
});
})
);
});
</template>
<template id="manifest" name="PWA manifest">
{
"name": "<t t-esc="pwa_name"/>",
"short_name": "<t t-esc="pwa_short_name"/>",
"icons": [{
"src": "<t t-esc="icon128x128"/>",
"sizes": "128x128",
"type": "image/png"
}, {
"src": "<t t-esc="icon144x144"/>",
"sizes": "144x144",
"type": "image/png"
}, {
"src": "<t t-esc="icon152x152"/>",
"sizes": "152x152",
"type": "image/png"
}, {
"src": "<t t-esc="icon192x192"/>",
"sizes": "192x192",
"type": "image/png"
}, {
"src": "<t t-esc="icon256x256"/>",
"sizes": "256x256",
"type": "image/png"
}, {
"src": "<t t-esc="icon512x512"/>",
"sizes": "512x512",
"type": "image/png"
}],
"start_url": "/web",
"display": "standalone",
"background_color": "<t t-esc="background_color"/>",
"theme_color": "<t t-esc="theme_color"/>"
}
</template>
</odoo>