diff --git a/document_quick_access/README.rst b/document_quick_access/README.rst new file mode 100644 index 0000000000..06d240414e --- /dev/null +++ b/document_quick_access/README.rst @@ -0,0 +1,108 @@ +===================== +Document Quick Access +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:60573be03baaa32601fb6a0a4bf5281e95aa17a7e9c77d1db074ea4d78f09fd2 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fserver--ux-lightgray.png?logo=github + :target: https://github.com/OCA/server-ux/tree/16.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-16-0/server-ux-16-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=16.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..baba4f97bd --- /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": "16.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.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..4e6bd8554a --- /dev/null +++ b/document_quick_access/i18n/document_quick_access.pot @@ -0,0 +1,130 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_quick_access +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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 +#: code:addons/document_quick_access/models/document_quick_access_rule.py:0 +#, python-format +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__archive_uid +msgid "Last Archived by" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__archive_date +msgid "Last Archived on" +msgstr "" + +#. 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 "" + +#. 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 +#: code:addons/document_quick_access/models/document_quick_access_rule.py:0 +#, python-format +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 +#. openerp-web +#: code:addons/document_quick_access/static/src/xml/document_quick_access_launcher.xml:0 +#, python-format +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..283a54e258 --- /dev/null +++ b/document_quick_access/i18n/es.po @@ -0,0 +1,136 @@ +# 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 +#: 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__archive_uid +msgid "Last Archived by" +msgstr "" + +#. module: document_quick_access +#: model:ir.model.fields,field_description:document_quick_access.field_document_quick_access_rule__archive_date +msgid "Last Archived on" +msgstr "" + +#. 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 +#: 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 +#. openerp-web +#: 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/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..28da1e62cb --- /dev/null +++ b/document_quick_access/models/base.py @@ -0,0 +1,17 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class Base(models.AbstractModel): + _inherit = "base" + + def get_quick_access_code(self): + self.ensure_one() + rule = self.env["document.quick.access.rule"].search( + [("model_id.model", "=", self._name)], 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..cb4198c275 --- /dev/null +++ b/document_quick_access/models/document_quick_access_rule.py @@ -0,0 +1,102 @@ +# 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, "_get_code_%s" % 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" + ) + + def _get_code_standard(self, record): + return "{},{}".format(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": _("Document cannot be found"), + } + ), + } + record.check_access_rights("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, "_check_code_%s" % barcode_format)(code): + record = getattr(self, "_read_code_%s" % barcode_format)(code) + if record and self.search( + [ + ("model_id.model", "=", record._name), + ("barcode_format", "=", barcode_format), + ] + ): + return record + raise UserError(_("No format has been found for this record")) diff --git a/document_quick_access/readme/CONFIGURE.rst b/document_quick_access/readme/CONFIGURE.rst new file mode 100644 index 0000000000..f5b30b477e --- /dev/null +++ b/document_quick_access/readme/CONFIGURE.rst @@ -0,0 +1,3 @@ +# 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.rst b/document_quick_access/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..26cc118d32 --- /dev/null +++ b/document_quick_access/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Enric Tobella +* [APSL](https://apsl.tech): + * Antoni Marroig \ No newline at end of file diff --git a/document_quick_access/readme/DESCRIPTION.rst b/document_quick_access/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..c7e41ce27e --- /dev/null +++ b/document_quick_access/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +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.rst b/document_quick_access/readme/ROADMAP.rst new file mode 100644 index 0000000000..9325de0c3a --- /dev/null +++ b/document_quick_access/readme/ROADMAP.rst @@ -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.rst b/document_quick_access/readme/USAGE.rst new file mode 100644 index 0000000000..9b23b78b4a --- /dev/null +++ b/document_quick_access/readme/USAGE.rst @@ -0,0 +1,3 @@ +# 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..783b40e23b --- /dev/null +++ b/document_quick_access/static/description/index.html @@ -0,0 +1,449 @@ + + + + + + +Document Quick Access + + + +
+

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.js b/document_quick_access/static/src/js/document_quick_access_launcher.js new file mode 100644 index 0000000000..5bc31d29d0 --- /dev/null +++ b/document_quick_access/static/src/js/document_quick_access_launcher.js @@ -0,0 +1,33 @@ +odoo.define("document_quick_access.document_quick_access_launcher", function (require) { + "use strict"; + + var SystrayMenu = require("web.SystrayMenu"); + var Widget = require("web.Widget"); + var LauncherMenu = Widget.extend({ + template: "document_quick_access_launcher.view.Menu", + events: { + click: "on_click_find_document", + }, + + on_click_find_document: function (event) { + event.preventDefault(); + event.stopPropagation(); + var context = {}; + context.default_model = "document.quick.access.rule"; + context.default_method = "read_code_action"; + return this.do_action({ + type: "ir.actions.act_window", + name: "Search QR", + res_model: "barcode.action", + views: [[false, "form"]], + target: "new", + context: context, + }); + }, + }); + + SystrayMenu.Items.push(LauncherMenu); + return { + LauncherMenu: LauncherMenu, + }; +}); 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..c42427e21c --- /dev/null +++ b/document_quick_access/static/src/xml/document_quick_access_launcher.xml @@ -0,0 +1,18 @@ + + + + + + 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..f5321ad269 --- /dev/null +++ b/document_quick_access/tests/test_document_quick_access.py @@ -0,0 +1,53 @@ +# 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.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.toggle_active() + 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.toggle_active() + 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..509a930fb6 --- /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 + tree,form + [] + {} + + + Document Quick Access Rule + + + + + diff --git a/requirements.txt b/requirements.txt index dd54de45b9..26f21814f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ # generated from manifests external_dependencies +pdf2image pyrfc6266 +pyzbar responses diff --git a/setup/document_quick_access/odoo/addons/document_quick_access b/setup/document_quick_access/odoo/addons/document_quick_access new file mode 120000 index 0000000000..b81fc28a51 --- /dev/null +++ b/setup/document_quick_access/odoo/addons/document_quick_access @@ -0,0 +1 @@ +../../../../document_quick_access \ No newline at end of file diff --git a/setup/document_quick_access/setup.py b/setup/document_quick_access/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/document_quick_access/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)