Skip to content

Commit

Permalink
[ADD] web_pwa_customize: New module
Browse files Browse the repository at this point in the history
TT51658
  • Loading branch information
victoralmau committed Nov 11, 2024
1 parent 990d84e commit 14d1751
Show file tree
Hide file tree
Showing 19 changed files with 1,012 additions and 0 deletions.
100 changes: 100 additions & 0 deletions web_pwa_customize/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
=================
Web Pwa Customize
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4a63e846d259636f1c4cd9c622f602c5a66bf775ab189162f90c00b3e278c7af
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/17.0/web_pwa_customize
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_pwa_customize
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to configure data for Progressive Web App: Short
name, Background color, Theme color and Icon.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

The existing definitions in the old web_pwa_oca of 16.0 (not existing or
customizable in core) are maintained.

Configuration
=============

#. Go to Settings > General Settings. #. In the 'Progressive Web App'
section you can configure all the data.

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_pwa_customize%0Aversion:%2017.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
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Víctor Martínez
- Pedro M. Baeza

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-victoralmau| image:: https://github.com/victoralmau.png?size=40px
:target: https://github.com/victoralmau
:alt: victoralmau

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/web <https://github.com/OCA/web/tree/17.0/web_pwa_customize>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions web_pwa_customize/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
14 changes: 14 additions & 0 deletions web_pwa_customize/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Web Pwa Customize",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"version": "17.0.1.0.0",
"depends": ["web"],
"license": "AGPL-3",
"category": "Website",
"installable": True,
"maintainers": ["victoralmau"],
"data": ["views/res_config_settings_views.xml"],
}
1 change: 1 addition & 0 deletions web_pwa_customize/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import webmanifest
71 changes: 71 additions & 0 deletions web_pwa_customize/controllers/webmanifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import json

from odoo import http
from odoo.http import request
from odoo.tools import ustr

from odoo.addons.web.controllers import webmanifest


class WebManifest(webmanifest.WebManifest):
def _get_pwa_manifest_icons(self, pwa_icon):
icons = []

Check warning on line 14 in web_pwa_customize/controllers/webmanifest.py

View check run for this annotation

Codecov / codecov/patch

web_pwa_customize/controllers/webmanifest.py#L14

Added line #L14 was not covered by tests
if not pwa_icon.mimetype.startswith("image/svg"):
all_icons = (

Check warning on line 16 in web_pwa_customize/controllers/webmanifest.py

View check run for this annotation

Codecov / codecov/patch

web_pwa_customize/controllers/webmanifest.py#L16

Added line #L16 was not covered by tests
request.env["ir.attachment"]
.sudo()
.search(
[
("url", "like", "/web_pwa_customize/icon"),
(
"url",
"not like",
"/web_pwa_customize/icon.",
), # Get only resized icons
]
)
)
for icon in all_icons:
icon_size_name = icon.url.split("/")[-1].lstrip("icon").split(".")[0]
icons.append(

Check warning on line 32 in web_pwa_customize/controllers/webmanifest.py

View check run for this annotation

Codecov / codecov/patch

web_pwa_customize/controllers/webmanifest.py#L31-L32

Added lines #L31 - L32 were not covered by tests
{"src": icon.url, "sizes": icon_size_name, "type": icon.mimetype}
)
else:
icons = [

Check warning on line 36 in web_pwa_customize/controllers/webmanifest.py

View check run for this annotation

Codecov / codecov/patch

web_pwa_customize/controllers/webmanifest.py#L36

Added line #L36 was not covered by tests
{
"src": pwa_icon.url,
"sizes": "128x128 144x144 152x152 192x192 256x256 512x512",
"type": pwa_icon.mimetype,
}
]
return icons

Check warning on line 43 in web_pwa_customize/controllers/webmanifest.py

View check run for this annotation

Codecov / codecov/patch

web_pwa_customize/controllers/webmanifest.py#L43

Added line #L43 was not covered by tests

@http.route(
"/web/manifest.webmanifest", type="http", auth="public", methods=["GET"]
)
def webmanifest(self):
"""Call super and overwrite the values that we want."""
res = super().webmanifest()
manifest = json.loads(res.response[0])
icp = request.env["ir.config_parameter"].sudo()
manifest["short_name"] = icp.get_param("pwa.manifest.short_name", "Odoo")
manifest["background_color"] = icp.get_param(
"pwa.manifest.background_color", "#714B67"
)
manifest["theme_color"] = icp.get_param("pwa.manifest.theme_color", "#714B67")
pwa_icon = (
request.env["ir.attachment"]
.sudo()
.search([("url", "like", "/web_pwa_customize/icon.")])
)
if pwa_icon:
manifest["icons"] = self._get_pwa_manifest_icons(pwa_icon)

Check warning on line 64 in web_pwa_customize/controllers/webmanifest.py

View check run for this annotation

Codecov / codecov/patch

web_pwa_customize/controllers/webmanifest.py#L64

Added line #L64 was not covered by tests
body = json.dumps(manifest, default=ustr)
return request.make_response(
body,
[
("Content-Type", "application/manifest+json"),
],
)
83 changes: 83 additions & 0 deletions web_pwa_customize/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_pwa_customize
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-08 16:57+0000\n"
"PO-Revision-Date: 2024-11-08 16:57+0000\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_customize
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "<span class=\"d-block w-75 py-2\">Background Color</span>"
msgstr "<span class=\"d-block w-75 py-2\">Color de fondo</span>"

#. module: web_pwa_customize
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "<span class=\"d-block w-75 py-2\">Theme Color</span>"
msgstr "<span class=\"d-block w-75 py-2\">Color del tema</span>"

#. module: web_pwa_customize
#: model:ir.model.fields,field_description:web_pwa_customize.field_res_config_settings__pwa_background_color
msgid "Background Color"
msgstr "Color de fondo"

#. module: web_pwa_customize
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "Colors"
msgstr "Colores"

#. module: web_pwa_customize
#: model:ir.model,name:web_pwa_customize.model_res_config_settings
msgid "Config Settings"
msgstr "Ajustes de configuración"

#. module: web_pwa_customize
#: model:ir.model.fields,field_description:web_pwa_customize.field_res_config_settings__pwa_icon
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "Icon"
msgstr "Icono"

#. module: web_pwa_customize
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "Odoo"
msgstr "Odoo"

#. module: web_pwa_customize
#: model:ir.model.fields,field_description:web_pwa_customize.field_res_config_settings__pwa_theme_color
msgid "Theme Color"
msgstr "Color del tema"

#. module: web_pwa_customize
#: model:ir.model.fields,field_description:web_pwa_customize.field_res_config_settings__pwa_short_name
msgid "Web App Short Name"
msgstr "Nombre corto de la aplicación"

#. module: web_pwa_customize
#. odoo-python
#: code:addons/web_pwa_customize/models/res_config_settings.py:0
#, 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_customize
#. odoo-python
#: code:addons/web_pwa_customize/models/res_config_settings.py:0
#, python-format
msgid "You can only upload SVG or PNG files. Found: %s."
msgstr "Solo puedes cargar archivos SVG o PNG. Encontrado: %s."

#. module: web_pwa_customize
#. odoo-python
#: code:addons/web_pwa_customize/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 más de 2 MB."
83 changes: 83 additions & 0 deletions web_pwa_customize/i18n/web_pwa_customize.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_pwa_customize
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-08 16:56+0000\n"
"PO-Revision-Date: 2024-11-08 16:56+0000\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_customize
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "<span class=\"d-block w-75 py-2\">Background Color</span>"
msgstr ""

#. module: web_pwa_customize
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "<span class=\"d-block w-75 py-2\">Theme Color</span>"
msgstr ""

#. module: web_pwa_customize
#: model:ir.model.fields,field_description:web_pwa_customize.field_res_config_settings__pwa_background_color
msgid "Background Color"
msgstr ""

#. module: web_pwa_customize
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "Colors"
msgstr ""

#. module: web_pwa_customize
#: model:ir.model,name:web_pwa_customize.model_res_config_settings
msgid "Config Settings"
msgstr ""

#. module: web_pwa_customize
#: model:ir.model.fields,field_description:web_pwa_customize.field_res_config_settings__pwa_icon
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "Icon"
msgstr ""

#. module: web_pwa_customize
#: model_terms:ir.ui.view,arch_db:web_pwa_customize.res_config_settings_view_form
msgid "Odoo"
msgstr ""

#. module: web_pwa_customize
#: model:ir.model.fields,field_description:web_pwa_customize.field_res_config_settings__pwa_theme_color
msgid "Theme Color"
msgstr ""

#. module: web_pwa_customize
#: model:ir.model.fields,field_description:web_pwa_customize.field_res_config_settings__pwa_short_name
msgid "Web App Short Name"
msgstr ""

#. module: web_pwa_customize
#. odoo-python
#: code:addons/web_pwa_customize/models/res_config_settings.py:0
#, python-format
msgid "You can only upload PNG files bigger than 512x512"
msgstr ""

#. module: web_pwa_customize
#. odoo-python
#: code:addons/web_pwa_customize/models/res_config_settings.py:0
#, python-format
msgid "You can only upload SVG or PNG files. Found: %s."
msgstr ""

#. module: web_pwa_customize
#. odoo-python
#: code:addons/web_pwa_customize/models/res_config_settings.py:0
#, python-format
msgid "You can't upload a file with more than 2 MB."
msgstr ""
1 change: 1 addition & 0 deletions web_pwa_customize/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_config_settings
Loading

0 comments on commit 14d1751

Please sign in to comment.