Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [MIG] document_quick_access_folder_auto_classification: Migration to 16.0 #906

Open
wants to merge 29 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2af4ab8
[ADD] document_quick_access_folder_classification
etobella Jun 5, 2019
e638852
[UPD] Update document_quick_access_folder_auto_classification.pot
oca-travis Nov 29, 2019
2269312
[UPD] README.rst
OCA-git-bot Nov 29, 2019
33dafd8
[FIX] protect import
hbrunn Jan 9, 2020
2aa1140
document_quick_access_folder_auto_classification 11.0.1.0.1
OCA-git-bot Jan 21, 2020
05943f5
[12.0][MIG] document_quick_access_folder_auto_classification
Mar 4, 2020
a6695ed
[IMP] document_quick_access_folder_auto_classification: black, isort
JoanSForgeFlow Mar 12, 2020
46eaab9
[MIG] document_quick_access_folder_auto_classification: Migration to …
JoanSForgeFlow Mar 12, 2020
1d03bb5
[UPD] Update document_quick_access_folder_auto_classification.pot
oca-travis Mar 18, 2020
b57af41
[UPD] README.rst
OCA-git-bot Mar 18, 2020
bffabdd
pre-commit update
sbidoul Apr 22, 2020
1522bab
[IMP] document_quick_access_folder_auto_classification: isort, black,…
fshah-initos Jun 16, 2021
3670a65
[MIG] document_quick_access_folder_auto_classification: Migration to …
hkapatel-initos Sep 9, 2021
4061926
[UPD] Update document_quick_access_folder_auto_classification.pot
oca-travis Oct 13, 2021
d0bc781
[UPD] README.rst
OCA-git-bot Oct 13, 2021
69fa314
[REF] document_quick_access_folder_auto_classification: Add dependenc…
etobella Feb 8, 2022
0146812
[MIG] document_quick_access_folder_auto_classification: Migration to …
JasminSForgeFlow Feb 8, 2022
27582f6
[FIX] document_quick_access_folder_auto_classification: create base_d…
LoisRForgeFlow Feb 15, 2022
2f6aa96
[FIX] document_quick_access_folder_auto_classification: dependencies
alexey-pelykh Jul 13, 2022
9b86685
[FIX] document_quick_access_folder_auto_classification: don't rely on…
etobella Jul 13, 2022
4df5f8f
[FIX] document_quick_access_folder_auto_classification: fix calls to …
LoisRForgeFlow Jul 21, 2022
116c069
[UPD] Update document_quick_access_folder_auto_classification.pot
Jul 21, 2022
f581b8f
[UPD] README.rst
OCA-git-bot Jul 21, 2022
1675e85
[FIX] document_quick_access_folder_auto_classification: remove dead code
LoisRForgeFlow May 26, 2022
381916c
[UPD] Update document_quick_access_folder_auto_classification.pot
Jul 25, 2022
7f45068
document_quick_access_folder_auto_classification 15.0.1.1.0
OCA-git-bot Jul 25, 2022
c0eb296
[UPD] README.rst
OCA-git-bot Sep 3, 2023
7b44abf
[IMP] document_quick_access_folder_auto_classification: pre-commit au…
luisDIXMIT Jun 25, 2024
bdddaa3
[MIG] document_quick_access_folder_auto_classification: Migration to …
luisDIXMIT Jun 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions document_quick_access_folder_auto_classification/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
================================================
Document Quick Access Folder Auto Classification
================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:14edc6aa1a5f02796dcc54b02bbaae83f3915aeb6d90a1d30ee32988de5f7170
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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_folder_auto_classification
: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_folder_auto_classification
: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 creates a job that scans all files from a storage and attaches them
to its record. The record is found using the document quick access rules.

**Table of contents**

.. contents::
:local:

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

# Create an storage on your system using the storage project from OCA

Usage
=====

Users can drop the files on the folder (You may be able to configure your
scanner to send the files directly).
Then, they will be able to see the files attached to the expected record.
If two records matches the rules, it will be attached to both (two QRs).

If the file matches no rules, it will be attached as a non processed documents.
Users should be able to assign which record to use

# Access `Documents to process`
# Select a non processed document
# Assign or reject the document. When assigning it, the record will be asked.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/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/server-ux/issues/new?body=module:%20document_quick_access_folder_auto_classification%0Aversion:%2016.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
~~~~~~~

* Creu Blanca

Contributors
~~~~~~~~~~~~

* Enric Tobella <etobella@creublanca.es>
* Foram Shah <foram.shah@initos.com>

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-etobella|

This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/16.0/document_quick_access_folder_auto_classification>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions document_quick_access_folder_auto_classification/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import components
from . import models
from . import wizards
25 changes: 25 additions & 0 deletions document_quick_access_folder_auto_classification/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2019 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Document Quick Access Folder Auto Classification",
"summary": """
Auto classification of Documents after reading a QR""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-ux",
"depends": ["document_quick_access", "edi_oca"],
"external_dependencies": {
"deb": ["libzbar0", "poppler-utils"],
"python": ["pyzbar", "pdf2image"],
},
"data": [
"data/edi_data.xml",
"security/security.xml",
"security/ir.model.access.csv",
"wizards/document_quick_access_missing_assign.xml",
"views/edi_exchange_record.xml",
],
"maintainers": ["etobella"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import document_quick_access_process
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright 2021 Creu Blanca
# @author: Enric Tobella
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import base64
import logging
import traceback
from io import StringIO

from odoo import _
from odoo.exceptions import UserError

from odoo.addons.component.core import Component

_logger = logging.getLogger(__name__)

try:
from pyzbar.pyzbar import ZBarSymbol, decode
except (ImportError, IOError) as err:
_logger.warning(err)

Check warning on line 20 in document_quick_access_folder_auto_classification/components/document_quick_access_process.py

View check run for this annotation

Codecov / codecov/patch

document_quick_access_folder_auto_classification/components/document_quick_access_process.py#L19-L20

Added lines #L19 - L20 were not covered by tests
try:
import pdf2image
from pdf2image.exceptions import (
PDFInfoNotInstalledError,
PDFPageCountError,
PDFSyntaxError,
)
except (ImportError, IOError) as err:
_logger.warning(err)

Check warning on line 29 in document_quick_access_folder_auto_classification/components/document_quick_access_process.py

View check run for this annotation

Codecov / codecov/patch

document_quick_access_folder_auto_classification/components/document_quick_access_process.py#L28-L29

Added lines #L28 - L29 were not covered by tests


class EdiDocumentQuickAccessProcess(Component):
_name = "edi.input.process.document.quick.access"
_usage = "input.process"
_backend_type = "document_quick_access"
_exchange_type = "document_quick_access"
_inherit = "edi.component.input.mixin"

def process(self):
data = self.exchange_record.exchange_file
records = self._search_document_pdf(data)
for record in records:
self.env["ir.attachment"].create(self._get_attachment_vals(record))
if records:
record = records[0]
self.exchange_record.write({"res_id": record.id, "model": record._name})
elif self.env.context.get("document_quick_access_reject_file"):
return
else:
raise UserError(_("No file found"))

def _get_attachment_vals(self, record):
return {
"name": self.exchange_record.exchange_filename,
"datas": self.exchange_record.exchange_file,
"res_id": record.id,
"res_model": record._name,
}

def _search_document_pdf(self, datas):
if self.env.context.get("document_quick_access_reject_file"):
return []
if self.env.context.get("force_object_process"):
return [self.env.context["force_object_process"]]
records = []
try:
images = pdf2image.convert_from_bytes(base64.b64decode(datas))
except (PDFInfoNotInstalledError, PDFPageCountError, PDFSyntaxError) as e:
buff = StringIO()
traceback.print_exc(file=buff)
_logger.warning(buff.getvalue())
raise UserError(str(e)) from e

Check warning on line 72 in document_quick_access_folder_auto_classification/components/document_quick_access_process.py

View check run for this annotation

Codecov / codecov/patch

document_quick_access_folder_auto_classification/components/document_quick_access_process.py#L68-L72

Added lines #L68 - L72 were not covered by tests
for im in images:
records += self._search_pil_image(im)
return records

def _search_pil_image(self, image):
results = decode(image, symbols=[ZBarSymbol.QRCODE])
records = []
rule_obj = self.env["document.quick.access.rule"]
for result in results:
record = rule_obj.with_context(no_raise_document_access=True).read_code(
result.data.decode("utf-8")
)
if record and record not in records:
records += record
return records
18 changes: 18 additions & 0 deletions document_quick_access_folder_auto_classification/data/edi_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="backend_type" model="edi.backend.type">
<field name="name">Document quick access</field>
<field name="code">document_quick_access</field>
</record>
<record id="exchange_type" model="edi.exchange.type">
<field name="name">Document quick access</field>
<field name="code">document_quick_access</field>
<field name="backend_type_id" ref="backend_type" />
<field name="direction">input</field>
<field name="exchange_filename_pattern" />
</record>
<record id="edi_backend" model="edi.backend">
<field name="name">Document quick access auto classification</field>
<field name="backend_type_id" ref="backend_type" />
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * document_quick_access_folder_auto_classification
#
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_folder_auto_classification
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_assign_form_view
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_form_view
msgid "Assign"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:res.groups,name:document_quick_access_folder_auto_classification.group_missing_document
msgid "Assigner"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_assign_form_view
msgid "Cancel"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign__create_uid
msgid "Created by"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign__create_date
msgid "Created on"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign__display_name
msgid "Display Name"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.actions.act_window,name:document_quick_access_folder_auto_classification.document_quick_access_missing_act_window
msgid "Document Quick Access Missing"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.actions.act_window,name:document_quick_access_folder_auto_classification.document_quick_access_missing_assign_act_window
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_assign_form_view
msgid "Document Quick Access Missing Assign"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model,name:document_quick_access_folder_auto_classification.model_document_quick_access_rule
msgid "Document Quick Access Rule"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.ui.menu,name:document_quick_access_folder_auto_classification.document_quick_access_missing_menu
msgid "Documents to process"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign__exchange_record_id
msgid "Exchange Record"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign__id
msgid "ID"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign____last_update
msgid "Last Modified on"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign__write_uid
msgid "Last Updated by"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign__write_date
msgid "Last Updated on"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.module.category,name:document_quick_access_folder_auto_classification.ir_module_category_missing_document
msgid "Missing Documents"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: code:addons/document_quick_access_folder_auto_classification/components/document_quick_access_process.py:0
#, python-format
msgid "No file found"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model.fields,field_description:document_quick_access_folder_auto_classification.field_document_quick_access_missing_assign__object_id
msgid "Object"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_search_view
msgid "Pending"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_search_view
msgid "Processed"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_form_view
msgid "Reject"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_search_view
msgid "Rejected"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model_terms:ir.ui.view,arch_db:document_quick_access_folder_auto_classification.document_quick_access_missing_form_view
msgid "Related record"
msgstr ""

#. module: document_quick_access_folder_auto_classification
#: model:ir.model,name:document_quick_access_folder_auto_classification.model_document_quick_access_missing_assign
msgid "document.quick.access.missing.assign"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import document_quick_access_rule
Loading
Loading