diff --git a/document_quick_access/README.rst b/document_quick_access/README.rst new file mode 100644 index 0000000000..9097d43d4a --- /dev/null +++ b/document_quick_access/README.rst @@ -0,0 +1,113 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +===================== +Document Quick Access +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:efcb9ab24743de674a8f8003956a8fe6ab9ceb051a6985cb6482a21a4496f3c6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fserver--ux-lightgray.png?logo=github + :target: https://github.com/OCA/server-ux/tree/19.0/document_quick_access + :alt: OCA/server-ux +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-ux-19-0/server-ux-19-0-document_quick_access + :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/server-ux&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to search any kind of records through a launcher. +With this, we can add a QR in our reports in order to search elements +faster. It could be used to add this QR (on a label) on external +documents. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +# Access on developer mode # Access Settings > Technical > Document +Quick Access # Create a record selecting the model, format and priority + +Usage +===== + +# Click on the QR button upper right in the navbar or access to it with +Alt + Shift + Q # A Pop up will be opened. You can scan a QR / barcode # +If the QR / barcode is found, you will be redirected to the record view + +Known issues / Roadmap +====================== + +- It would be interesting to be able to read the QR without clicking the + button. Maybe using a shortcut or directly accessing it. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Creu Blanca + +Contributors +------------ + +- Enric Tobella +- [APSL](https://apsl.tech): + + - Antoni Marroig + +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-etobella| image:: https://github.com/etobella.png?size=40px + :target: https://github.com/etobella + :alt: etobella + +Current `maintainer `__: + +|maintainer-etobella| + +This module is part of the `OCA/server-ux `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/document_quick_access/__init__.py b/document_quick_access/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/document_quick_access/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/document_quick_access/__manifest__.py b/document_quick_access/__manifest__.py new file mode 100644 index 0000000000..dac6b7c217 --- /dev/null +++ b/document_quick_access/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Document Quick Access", + "summary": """ + Document quick access""", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "author": "Creu Blanca,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-ux", + "maintainers": ["etobella"], + "depends": ["web", "barcode_action"], + "external_dependencies": {"python": ["pyzbar", "pdf2image"]}, + "data": [ + "security/ir.model.access.csv", + "views/document_quick_access_rule.xml", + ], + "assets": { + "web.assets_backend": [ + "document_quick_access/static/src/js/document_quick_access_launcher.esm.js", + "document_quick_access/static/src/xml/document_quick_access_launcher.xml", + ], + }, +} diff --git a/document_quick_access/i18n/document_quick_access.pot b/document_quick_access/i18n/document_quick_access.pot new file mode 100644 index 0000000000..52a1b8ade0 --- /dev/null +++ b/document_quick_access/i18n/document_quick_access.pot @@ -0,0 +1,114 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_quick_access +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__active +msgid "Active" +msgstr "" + +#. module: document_quick_access +#: model_terms:ir.ui.view,arch_db:document_quick_access.document_quick_access_rule_form_view +msgid "Archived" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__barcode_format +msgid "Barcode Format" +msgstr "" + +#. module: document_quick_access +#: model:ir.model,name:document_quick_access.model_base +msgid "Base" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields.selection,name:document_quick_access.selection__document_quick_access_rule__barcode_format__b64_standard +msgid "Base64" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__create_uid +msgid "Created by" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__create_date +msgid "Created on" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__display_name +msgid "Display Name" +msgstr "" + +#. module: document_quick_access +#: model:ir.actions.act_window,name:document_quick_access.document_quick_access_rule_act_window +#: model:ir.model,name:document_quick_access.model_document_quick_access_rule +#: model:ir.ui.menu,name:document_quick_access.document_quick_access_rule_menu +msgid "Document Quick Access Rule" +msgstr "" + +#. module: document_quick_access +#. odoo-python +#: code:addons/document_quick_access/models/document_quick_access_rule.py:0 +msgid "Document cannot be found" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__id +msgid "ID" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__write_date +msgid "Last Updated on" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__model_id +msgid "Model" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__name +msgid "Name" +msgstr "" + +#. module: document_quick_access +#. odoo-python +#: code:addons/document_quick_access/models/document_quick_access_rule.py:0 +msgid "No format has been found for this record" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__priority +msgid "Priority" +msgstr "" + +#. module: document_quick_access +#. odoo-javascript +#: code:addons/document_quick_access/static/src/xml/document_quick_access_launcher.xml:0 +msgid "QR search" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields.selection,name:document_quick_access.selection__document_quick_access_rule__barcode_format__standard +msgid "Standard" +msgstr "" diff --git a/document_quick_access/i18n/es.po b/document_quick_access/i18n/es.po new file mode 100644 index 0000000000..9d03a49f80 --- /dev/null +++ b/document_quick_access/i18n/es.po @@ -0,0 +1,128 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_quick_access +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-03-16 11:46+0000\n" +"Last-Translator: Ana Suárez \n" +"Language-Team: none\n" +"Language: es\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: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__active +msgid "Active" +msgstr "Activo" + +#. module: document_quick_access +#: model_terms:ir.ui.view,arch_db:document_quick_access.document_quick_access_rule_form_view +msgid "Archived" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__barcode_format +msgid "Barcode Format" +msgstr "Formato" + +#. module: document_quick_access +#: model:ir.model,name:document_quick_access.model_base +msgid "Base" +msgstr "Base" + +#. module: document_quick_access +#: model:ir.model.fields.selection,name:document_quick_access.selection__document_quick_access_rule__barcode_format__b64_standard +msgid "Base64" +msgstr "Base64" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__create_date +msgid "Created on" +msgstr "Creado en" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: document_quick_access +#: model:ir.actions.act_window,name:document_quick_access.document_quick_access_rule_act_window +#: model:ir.model,name:document_quick_access.model_document_quick_access_rule +#: model:ir.ui.menu,name:document_quick_access.document_quick_access_rule_menu +msgid "Document Quick Access Rule" +msgstr "Regla de acceso rápido" + +#. module: document_quick_access +#. odoo-python +#: code:addons/document_quick_access/models/document_quick_access_rule.py:0 +#, python-format +msgid "Document cannot be found" +msgstr "No se ha encontrado documento" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__id +msgid "ID" +msgstr "ID" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule____last_update +msgid "Last Modified on" +msgstr "Última modificación en" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__write_uid +msgid "Last Updated by" +msgstr "Última actualización de" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__write_date +msgid "Last Updated on" +msgstr "Última actualización en" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__model_id +msgid "Model" +msgstr "Modelo" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__name +msgid "Name" +msgstr "Nombre" + +#. module: document_quick_access +#. odoo-python +#: code:addons/document_quick_access/models/document_quick_access_rule.py:0 +#, python-format +msgid "No format has been found for this record" +msgstr "No se ha encontrado ningún formato para este registro" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__priority +msgid "Priority" +msgstr "Prioridad" + +#. module: document_quick_access +#. odoo-javascript +#: code:addons/document_quick_access/static/src/xml/document_quick_access_launcher.xml:0 +#, python-format +msgid "QR search" +msgstr "Buscar QR" + +#. module: document_quick_access +#: model:ir.model.fields.selection,name:document_quick_access.selection__document_quick_access_rule__barcode_format__standard +msgid "Standard" +msgstr "Estándar" + +#~ msgid "base" +#~ msgstr "base" diff --git a/document_quick_access/i18n/it.po b/document_quick_access/i18n/it.po new file mode 100644 index 0000000000..48612ec6d0 --- /dev/null +++ b/document_quick_access/i18n/it.po @@ -0,0 +1,125 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_quick_access +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-07-08 14:58+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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 5.6.2\n" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__active +msgid "Active" +msgstr "Attiva" + +#. module: document_quick_access +#: model_terms:ir.ui.view,arch_db:document_quick_access.document_quick_access_rule_form_view +msgid "Archived" +msgstr "In archivio" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__barcode_format +msgid "Barcode Format" +msgstr "Formato codice a barre" + +#. module: document_quick_access +#: model:ir.model,name:document_quick_access.model_base +msgid "Base" +msgstr "Base" + +#. module: document_quick_access +#: model:ir.model.fields.selection,name:document_quick_access.selection__document_quick_access_rule__barcode_format__b64_standard +msgid "Base64" +msgstr "Base64" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: document_quick_access +#: model:ir.actions.act_window,name:document_quick_access.document_quick_access_rule_act_window +#: model:ir.model,name:document_quick_access.model_document_quick_access_rule +#: model:ir.ui.menu,name:document_quick_access.document_quick_access_rule_menu +msgid "Document Quick Access Rule" +msgstr "Regola accesso rapido documento" + +#. module: document_quick_access +#. odoo-python +#: code:addons/document_quick_access/models/document_quick_access_rule.py:0 +#, python-format +msgid "Document cannot be found" +msgstr "Il documento non è presente" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__id +msgid "ID" +msgstr "ID" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__model_id +msgid "Model" +msgstr "Modello" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__name +msgid "Name" +msgstr "Nome" + +#. module: document_quick_access +#. odoo-python +#: code:addons/document_quick_access/models/document_quick_access_rule.py:0 +#, python-format +msgid "No format has been found for this record" +msgstr "Nessun formato trovato per questo record" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__priority +msgid "Priority" +msgstr "Priorità" + +#. module: document_quick_access +#. odoo-javascript +#: code:addons/document_quick_access/static/src/xml/document_quick_access_launcher.xml:0 +#, python-format +msgid "QR search" +msgstr "Ricerca QR" + +#. module: document_quick_access +#: model:ir.model.fields.selection,name:document_quick_access.selection__document_quick_access_rule__barcode_format__standard +msgid "Standard" +msgstr "Standard" diff --git a/document_quick_access/models/__init__.py b/document_quick_access/models/__init__.py new file mode 100644 index 0000000000..41ee6387d9 --- /dev/null +++ b/document_quick_access/models/__init__.py @@ -0,0 +1,2 @@ +from . import document_quick_access_rule +from . import base diff --git a/document_quick_access/models/base.py b/document_quick_access/models/base.py new file mode 100644 index 0000000000..6e6e3f1f55 --- /dev/null +++ b/document_quick_access/models/base.py @@ -0,0 +1,26 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models +from odoo.fields import Domain + + +class Base(models.AbstractModel): + _inherit = "base" + + def get_quick_access_code( + self, + ): + self.ensure_one() + model_id = ( + self.env["ir.model"] + .sudo() + .search(Domain("model", "=", self._name), limit=1) + .id + ) + rule = self.env["document.quick.access.rule"].search( + Domain("model_id", "=", model_id), limit=1 + ) + if not rule: + return False + return rule.get_code(self) diff --git a/document_quick_access/models/document_quick_access_rule.py b/document_quick_access/models/document_quick_access_rule.py new file mode 100644 index 0000000000..626df22090 --- /dev/null +++ b/document_quick_access/models/document_quick_access_rule.py @@ -0,0 +1,103 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import base64 +import binascii +import json +import re + +from odoo import api, fields, models +from odoo.exceptions import UserError + + +class DocumentQuickAccessRule(models.Model): + _name = "document.quick.access.rule" + _description = "Document Quick Access Rule" + _order = "priority,model_id" + + name = fields.Char(required=True) + priority = fields.Integer(default=16, required=True) + barcode_format = fields.Selection( + [("standard", "Standard"), ("b64_standard", "Base64")], + required=True, + default="standard", + ) + # All formats must have a function to determine the code from a record and + # get the record from the code + model_id = fields.Many2one("ir.model", required=True, ondelete="cascade") + active = fields.Boolean(default=True) + + def get_code(self, record): + self.ensure_one() + return getattr(self, f"_get_code_{self.barcode_format}")(record) + + def _get_code_b64_standard(self, record): + return base64.b64encode(self._get_code_standard(record).encode("utf-8")).decode( + "utf-8" + ) + + @api.model + def _get_code_standard(self, record): + return f"{record._name},{record.id}" + + def _check_code_b64_standard(self, code): + try: + aux_code = base64.b64decode(code.encode("utf-8"), validate=True) + except binascii.Error: + return False + return self._check_code_standard(aux_code.decode("utf-8")) + + def _check_code_standard(self, code): + return re.match("^[a-zA-Z0-9\\.]*,[0-9]*$", code) + + def _read_code_b64_standard(self, code): + aux_code = base64.b64decode(code.encode("utf-8")).decode("utf-8") + return self._read_code_standard(aux_code) + + def _read_code_standard(self, code): + params = code.split(",") + return self.env[params[0]].browse(int(params[1])).exists() + + def read_code_action(self, code): + try: + record = self.read_code(code) + except UserError: + return { + "type": "ir.actions.act_window", + "name": "Search QR", + "res_model": "barcode.action", + "views": [[False, "form"]], + "target": "new", + "context": json.dumps( + { + "default_model": "document.quick.access.rule", + "default_method": "read_code_action", + "default_state": "warning", + "default_status": self.env._("Document cannot be found"), + } + ), + } + record.check_access("read") + result = { + "type": "ir.actions.act_window", + "res_model": record._name, + "views": [[record.get_formview_id(), "form"]], + "res_id": record.id, + "target": "main", + } + return result + + @api.model + def read_code(self, code): + formats = self._fields["barcode_format"].selection + for barcode_format, _format_name in formats: + if getattr(self, f"_check_code_{barcode_format}")(code): + record = getattr(self, f"_read_code_{barcode_format}")(code) + if record and self.search( + [ + ("model_id.model", "=", record._name), + ("barcode_format", "=", barcode_format), + ] + ): + return record + raise UserError(self.env._("No format has been found for this record")) diff --git a/document_quick_access/pyproject.toml b/document_quick_access/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/document_quick_access/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/document_quick_access/readme/CONFIGURE.md b/document_quick_access/readme/CONFIGURE.md new file mode 100644 index 0000000000..cd1be99de9 --- /dev/null +++ b/document_quick_access/readme/CONFIGURE.md @@ -0,0 +1,2 @@ +\# Access on developer mode \# Access Settings \> Technical \> Document +Quick Access \# Create a record selecting the model, format and priority diff --git a/document_quick_access/readme/CONTRIBUTORS.md b/document_quick_access/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..3fafcc304f --- /dev/null +++ b/document_quick_access/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Enric Tobella \ +- \[APSL\](): + - Antoni Marroig \ diff --git a/document_quick_access/readme/DESCRIPTION.md b/document_quick_access/readme/DESCRIPTION.md new file mode 100644 index 0000000000..1d2d9b6826 --- /dev/null +++ b/document_quick_access/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module allows to search any kind of records through a launcher. +With this, we can add a QR in our reports in order to search elements +faster. It could be used to add this QR (on a label) on external +documents. diff --git a/document_quick_access/readme/ROADMAP.md b/document_quick_access/readme/ROADMAP.md new file mode 100644 index 0000000000..548b75c536 --- /dev/null +++ b/document_quick_access/readme/ROADMAP.md @@ -0,0 +1,2 @@ +- It would be interesting to be able to read the QR without clicking the + button. Maybe using a shortcut or directly accessing it. diff --git a/document_quick_access/readme/USAGE.md b/document_quick_access/readme/USAGE.md new file mode 100644 index 0000000000..a45123a2b7 --- /dev/null +++ b/document_quick_access/readme/USAGE.md @@ -0,0 +1,4 @@ +\# Click on the QR button upper right in the navbar or access to it with +Alt + Shift + Q \# A Pop up will be opened. You can scan a QR / barcode +\# If the QR / barcode is found, you will be redirected to the record +view diff --git a/document_quick_access/security/ir.model.access.csv b/document_quick_access/security/ir.model.access.csv new file mode 100644 index 0000000000..d0d9f1deeb --- /dev/null +++ b/document_quick_access/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_document_quick_access_rule_user,document.quick.access.rule.user,model_document_quick_access_rule,base.group_user,1,0,0,0 +access_document_quick_access_rule_manager,document.quick.acess.rule.manager,model_document_quick_access_rule,base.group_erp_manager,1,1,1,1 diff --git a/document_quick_access/static/description/icon.png b/document_quick_access/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/document_quick_access/static/description/icon.png differ diff --git a/document_quick_access/static/description/index.html b/document_quick_access/static/description/index.html new file mode 100644 index 0000000000..3220a26651 --- /dev/null +++ b/document_quick_access/static/description/index.html @@ -0,0 +1,459 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Document Quick Access

+ +

Beta License: AGPL-3 OCA/server-ux Translate me on Weblate Try me on Runboat

+

This module allows to search any kind of records through a launcher. +With this, we can add a QR in our reports in order to search elements +faster. It could be used to add this QR (on a label) on external +documents.

+

Table of contents

+ +
+

Configuration

+

# Access on developer mode # Access Settings > Technical > Document +Quick Access # Create a record selecting the model, format and priority

+
+
+

Usage

+

# Click on the QR button upper right in the navbar or access to it with +Alt + Shift + Q # A Pop up will be opened. You can scan a QR / barcode # +If the QR / barcode is found, you will be redirected to the record view

+
+
+

Known issues / Roadmap

+
    +
  • It would be interesting to be able to read the QR without clicking the +button. Maybe using a shortcut or directly accessing it.
  • +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Creu Blanca
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

etobella

+

This module is part of the OCA/server-ux project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/document_quick_access/static/src/js/document_quick_access_launcher.esm.js b/document_quick_access/static/src/js/document_quick_access_launcher.esm.js new file mode 100644 index 0000000000..0ac5ae6549 --- /dev/null +++ b/document_quick_access/static/src/js/document_quick_access_launcher.esm.js @@ -0,0 +1,30 @@ +/* @odoo-module */ + +import {Component} from "@odoo/owl"; +import {registry} from "@web/core/registry"; +import {useService} from "@web/core/utils/hooks"; + +export class DocumentQuickAccessSystrayItem extends Component { + static template = "document_quick_access_launcher.view.Menu"; + setup() { + this.action = useService("action"); + } + onClick(ev) { + ev.preventDefault(); + ev.stopPropagation(); + var context = {}; + context.default_model = "document.quick.access.rule"; + context.default_method = "read_code_action"; + this.action.doAction({ + type: "ir.actions.act_window", + name: "Search QR", + res_model: "barcode.action", + views: [[false, "form"]], + target: "new", + context: context, + }); + } +} +registry + .category("systray") + .add("document_quick_access_launcher", {Component: DocumentQuickAccessSystrayItem}); diff --git a/document_quick_access/static/src/xml/document_quick_access_launcher.xml b/document_quick_access/static/src/xml/document_quick_access_launcher.xml new file mode 100644 index 0000000000..c3fb0ee14b --- /dev/null +++ b/document_quick_access/static/src/xml/document_quick_access_launcher.xml @@ -0,0 +1,15 @@ + + + +
+ +
+
+
diff --git a/document_quick_access/tests/__init__.py b/document_quick_access/tests/__init__.py new file mode 100644 index 0000000000..85aedb49ed --- /dev/null +++ b/document_quick_access/tests/__init__.py @@ -0,0 +1 @@ +from . import test_document_quick_access diff --git a/document_quick_access/tests/test_document_quick_access.py b/document_quick_access/tests/test_document_quick_access.py new file mode 100644 index 0000000000..a00db438d2 --- /dev/null +++ b/document_quick_access/tests/test_document_quick_access.py @@ -0,0 +1,54 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.exceptions import UserError +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestDocumentQuickAccess(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.model = "res.partner" + cls.model_id = cls.env.ref("base.model_res_partner") + cls.rule = cls.env["document.quick.access.rule"].create( + { + "model_id": cls.model_id.id, + "name": "PARTNER", + "priority": 1, + "barcode_format": "standard", + } + ) + cls.partner = cls.env["res.partner"].create({"name": "Partner test"}) + + def test_generation(self): + code = self.partner.get_quick_access_code() + self.assertTrue(code) + partner = self.env["document.quick.access.rule"].read_code(code) + self.assertEqual(partner, self.partner) + action = self.env["document.quick.access.rule"].read_code_action(code) + self.assertEqual(action["res_model"], partner._name) + self.assertEqual(action["res_id"], partner.id) + + def test_not_found(self): + code = self.partner.get_quick_access_code() + self.assertTrue(code) + self.rule.action_archive() + with self.assertRaises(UserError): + self.env["document.quick.access.rule"].read_code(code) + action = self.env["document.quick.access.rule"].read_code_action(code) + self.assertEqual(action["res_model"], "barcode.action") + + def test_no_code(self): + self.rule.action_archive() + self.assertFalse(self.partner.get_quick_access_code()) + + def test_generation_b64(self): + self.rule.barcode_format = "b64_standard" + self.test_generation() + + def test_not_found_b64(self): + self.rule.barcode_format = "b64_standard" + self.test_not_found() diff --git a/document_quick_access/views/document_quick_access_rule.xml b/document_quick_access/views/document_quick_access_rule.xml new file mode 100644 index 0000000000..67362f379b --- /dev/null +++ b/document_quick_access/views/document_quick_access_rule.xml @@ -0,0 +1,72 @@ + + + + + document.quick.access.rule.form (in document_quick_access) + document.quick.access.rule + +
+
+ + + +

+ +

+ + + + + +
+ + + + + document.quick.access.rule.search (in document_quick_access) + document.quick.access.rule + + + + + + + + + + document.quick.access.rule.tree (in document_quick_access) + document.quick.access.rule + + + + + + + + + + Document Quick Access Rule + document.quick.access.rule + list,form + [] + {} + + + Document Quick Access Rule + + + + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..2186a97932 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +# generated from manifests external_dependencies +pdf2image +pyzbar diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000000..27da3aafeb --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-barcode_action @ git+https://github.com/OCA/server-ux.git@refs/pull/1290/head#subdirectory=barcode_action