diff --git a/bill_digitization/README.rst b/bill_digitization/README.rst new file mode 100755 index 000000000..8117b9ba4 --- /dev/null +++ b/bill_digitization/README.rst @@ -0,0 +1,42 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Bill Digitization +================= +This module creates bill from scanned bill document. + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +Developer: (V16) Sruthi Renjith, Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +License +------- +GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3) +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/bill_digitization/__init__.py b/bill_digitization/__init__.py new file mode 100644 index 000000000..5d4ea3a31 --- /dev/null +++ b/bill_digitization/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Sruthi Renjith (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import models +from . import wizard diff --git a/bill_digitization/__manifest__.py b/bill_digitization/__manifest__.py new file mode 100644 index 000000000..dbfbb35c9 --- /dev/null +++ b/bill_digitization/__manifest__.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Sruthi Renjith (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +{ + 'name': 'Bill Digitization', + 'version': '16.0.1.0.0', + 'category': 'Accounting', + 'summary': """Converting traditional paper-based bills into digital + formats.""", + 'description': """Reading scanned documents with extension .jpg, .jpeg and + .png using specialized hardware and converting them into + vendor bills in odoo. It makes use of the Optical Character + Recognition (OCR) technology to convert scanned images into + editable text""", + 'author': "Cybrosys Techno Solutions", + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base', 'base_accounting_kit'], + 'data': [ + 'security/ir.model.access.csv', + 'views/res_config_settings_views.xml', + 'wizard/digitize_bill_views.xml', + ], + 'assets': { + 'web.assets_backend': [ + 'bill_digitization/static/src/js/digitize_button.js', + 'bill_digitization/static/src/xml/digitize_button.xml', + ], + }, + 'external_dependencies': { + 'python': ['PIL', 'pytesseract'] + }, + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False +} diff --git a/bill_digitization/doc/RELEASE_NOTES.md b/bill_digitization/doc/RELEASE_NOTES.md new file mode 100755 index 000000000..82dc765f4 --- /dev/null +++ b/bill_digitization/doc/RELEASE_NOTES.md @@ -0,0 +1,5 @@ +## Module +#### 04.11.2023 +#### Version 16.0.1.0.0 +#### ADD +- Initial commit for Bill Digitization diff --git a/bill_digitization/models/__init__.py b/bill_digitization/models/__init__.py new file mode 100644 index 000000000..7488dfd9e --- /dev/null +++ b/bill_digitization/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Sruthi Renjith (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import res_config_settings diff --git a/bill_digitization/models/res_config_settings.py b/bill_digitization/models/res_config_settings.py new file mode 100644 index 000000000..00c41421a --- /dev/null +++ b/bill_digitization/models/res_config_settings.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Sruthi Renjith (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """ Class to add a boolean in config settings """ + _inherit = "res.config.settings" + + digitize_bill = fields.Boolean( + string="Digitize Bill", + config_parameter='bill_digitization.digitize_bill', + help="Enable the button to digitize bills") diff --git a/bill_digitization/security/ir.model.access.csv b/bill_digitization/security/ir.model.access.csv new file mode 100644 index 000000000..1ee85687a --- /dev/null +++ b/bill_digitization/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_digitize_bill_user,access.digitize.bill.user,model_digitize_bill,base.group_user,1,1,1,1 diff --git a/bill_digitization/static/description/assets/icons/cogs.png b/bill_digitization/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/bill_digitization/static/description/assets/icons/cogs.png differ diff --git a/bill_digitization/static/description/assets/icons/consultation.png b/bill_digitization/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/bill_digitization/static/description/assets/icons/consultation.png differ diff --git a/bill_digitization/static/description/assets/icons/ecom-black.png b/bill_digitization/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/bill_digitization/static/description/assets/icons/ecom-black.png differ diff --git a/bill_digitization/static/description/assets/icons/education-black.png b/bill_digitization/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/bill_digitization/static/description/assets/icons/education-black.png differ diff --git a/bill_digitization/static/description/assets/icons/hotel-black.png b/bill_digitization/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/bill_digitization/static/description/assets/icons/hotel-black.png differ diff --git a/bill_digitization/static/description/assets/icons/license.png b/bill_digitization/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/bill_digitization/static/description/assets/icons/license.png differ diff --git a/bill_digitization/static/description/assets/icons/lifebuoy.png b/bill_digitization/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/bill_digitization/static/description/assets/icons/lifebuoy.png differ diff --git a/bill_digitization/static/description/assets/icons/manufacturing-black.png b/bill_digitization/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/bill_digitization/static/description/assets/icons/manufacturing-black.png differ diff --git a/bill_digitization/static/description/assets/icons/pos-black.png b/bill_digitization/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/bill_digitization/static/description/assets/icons/pos-black.png differ diff --git a/bill_digitization/static/description/assets/icons/puzzle.png b/bill_digitization/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/bill_digitization/static/description/assets/icons/puzzle.png differ diff --git a/bill_digitization/static/description/assets/icons/restaurant-black.png b/bill_digitization/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/bill_digitization/static/description/assets/icons/restaurant-black.png differ diff --git a/bill_digitization/static/description/assets/icons/service-black.png b/bill_digitization/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/bill_digitization/static/description/assets/icons/service-black.png differ diff --git a/bill_digitization/static/description/assets/icons/trading-black.png b/bill_digitization/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/bill_digitization/static/description/assets/icons/trading-black.png differ diff --git a/bill_digitization/static/description/assets/icons/training.png b/bill_digitization/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/bill_digitization/static/description/assets/icons/training.png differ diff --git a/bill_digitization/static/description/assets/icons/update.png b/bill_digitization/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/bill_digitization/static/description/assets/icons/update.png differ diff --git a/bill_digitization/static/description/assets/icons/user.png b/bill_digitization/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/bill_digitization/static/description/assets/icons/user.png differ diff --git a/bill_digitization/static/description/assets/icons/wrench.png b/bill_digitization/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/bill_digitization/static/description/assets/icons/wrench.png differ diff --git a/bill_digitization/static/description/assets/misc/categories.png b/bill_digitization/static/description/assets/misc/categories.png new file mode 100755 index 000000000..bedf1e0b1 Binary files /dev/null and b/bill_digitization/static/description/assets/misc/categories.png differ diff --git a/bill_digitization/static/description/assets/misc/check-box.png b/bill_digitization/static/description/assets/misc/check-box.png new file mode 100755 index 000000000..42caf24b9 Binary files /dev/null and b/bill_digitization/static/description/assets/misc/check-box.png differ diff --git a/bill_digitization/static/description/assets/misc/compass.png b/bill_digitization/static/description/assets/misc/compass.png new file mode 100755 index 000000000..d5fed8faa Binary files /dev/null and b/bill_digitization/static/description/assets/misc/compass.png differ diff --git a/bill_digitization/static/description/assets/misc/config.png b/bill_digitization/static/description/assets/misc/config.png new file mode 100755 index 000000000..71915e76c Binary files /dev/null and b/bill_digitization/static/description/assets/misc/config.png differ diff --git a/bill_digitization/static/description/assets/misc/corporate.png b/bill_digitization/static/description/assets/misc/corporate.png new file mode 100755 index 000000000..2eb13edbf Binary files /dev/null and b/bill_digitization/static/description/assets/misc/corporate.png differ diff --git a/bill_digitization/static/description/assets/misc/customer-support.png b/bill_digitization/static/description/assets/misc/customer-support.png new file mode 100755 index 000000000..79efc72ed Binary files /dev/null and b/bill_digitization/static/description/assets/misc/customer-support.png differ diff --git a/bill_digitization/static/description/assets/misc/features.png b/bill_digitization/static/description/assets/misc/features.png new file mode 100755 index 000000000..b41769f77 Binary files /dev/null and b/bill_digitization/static/description/assets/misc/features.png differ diff --git a/bill_digitization/static/description/assets/misc/logo.png b/bill_digitization/static/description/assets/misc/logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/bill_digitization/static/description/assets/misc/logo.png differ diff --git a/bill_digitization/static/description/assets/misc/pictures.png b/bill_digitization/static/description/assets/misc/pictures.png new file mode 100755 index 000000000..56d255fe9 Binary files /dev/null and b/bill_digitization/static/description/assets/misc/pictures.png differ diff --git a/bill_digitization/static/description/assets/misc/pie-chart.png b/bill_digitization/static/description/assets/misc/pie-chart.png new file mode 100755 index 000000000..426e05244 Binary files /dev/null and b/bill_digitization/static/description/assets/misc/pie-chart.png differ diff --git a/bill_digitization/static/description/assets/misc/right-arrow.png b/bill_digitization/static/description/assets/misc/right-arrow.png new file mode 100755 index 000000000..730984a06 Binary files /dev/null and b/bill_digitization/static/description/assets/misc/right-arrow.png differ diff --git a/bill_digitization/static/description/assets/misc/star.png b/bill_digitization/static/description/assets/misc/star.png new file mode 100755 index 000000000..2eb9ab29f Binary files /dev/null and b/bill_digitization/static/description/assets/misc/star.png differ diff --git a/bill_digitization/static/description/assets/misc/support.png b/bill_digitization/static/description/assets/misc/support.png new file mode 100755 index 000000000..4f18b8b82 Binary files /dev/null and b/bill_digitization/static/description/assets/misc/support.png differ diff --git a/bill_digitization/static/description/assets/misc/whatsapp.png b/bill_digitization/static/description/assets/misc/whatsapp.png new file mode 100755 index 000000000..d513a5356 Binary files /dev/null and b/bill_digitization/static/description/assets/misc/whatsapp.png differ diff --git a/bill_digitization/static/description/assets/modules/module01.gif b/bill_digitization/static/description/assets/modules/module01.gif new file mode 100644 index 000000000..8f40aab85 Binary files /dev/null and b/bill_digitization/static/description/assets/modules/module01.gif differ diff --git a/bill_digitization/static/description/assets/modules/module02.png b/bill_digitization/static/description/assets/modules/module02.png new file mode 100644 index 000000000..15b141248 Binary files /dev/null and b/bill_digitization/static/description/assets/modules/module02.png differ diff --git a/bill_digitization/static/description/assets/modules/module03.png b/bill_digitization/static/description/assets/modules/module03.png new file mode 100644 index 000000000..489f44e86 Binary files /dev/null and b/bill_digitization/static/description/assets/modules/module03.png differ diff --git a/bill_digitization/static/description/assets/modules/module04.png b/bill_digitization/static/description/assets/modules/module04.png new file mode 100644 index 000000000..655347837 Binary files /dev/null and b/bill_digitization/static/description/assets/modules/module04.png differ diff --git a/bill_digitization/static/description/assets/modules/module05.png b/bill_digitization/static/description/assets/modules/module05.png new file mode 100644 index 000000000..dd2b151c6 Binary files /dev/null and b/bill_digitization/static/description/assets/modules/module05.png differ diff --git a/bill_digitization/static/description/assets/modules/module06.png b/bill_digitization/static/description/assets/modules/module06.png new file mode 100644 index 000000000..29bcb6544 Binary files /dev/null and b/bill_digitization/static/description/assets/modules/module06.png differ diff --git a/bill_digitization/static/description/assets/screenshots/boolean.png b/bill_digitization/static/description/assets/screenshots/boolean.png new file mode 100644 index 000000000..6a7427370 Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/boolean.png differ diff --git a/bill_digitization/static/description/assets/screenshots/button.png b/bill_digitization/static/description/assets/screenshots/button.png new file mode 100644 index 000000000..8e0e6afa8 Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/button.png differ diff --git a/bill_digitization/static/description/assets/screenshots/demo_bill1.jpg b/bill_digitization/static/description/assets/screenshots/demo_bill1.jpg new file mode 100644 index 000000000..784a45868 Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/demo_bill1.jpg differ diff --git a/bill_digitization/static/description/assets/screenshots/demo_bill2.png b/bill_digitization/static/description/assets/screenshots/demo_bill2.png new file mode 100644 index 000000000..0f78d8a0d Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/demo_bill2.png differ diff --git a/bill_digitization/static/description/assets/screenshots/hero.gif b/bill_digitization/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..386191ce1 Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/hero.gif differ diff --git a/bill_digitization/static/description/assets/screenshots/sample_bill.png b/bill_digitization/static/description/assets/screenshots/sample_bill.png new file mode 100644 index 000000000..28164a2e9 Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/sample_bill.png differ diff --git a/bill_digitization/static/description/assets/screenshots/vendor_bill.png b/bill_digitization/static/description/assets/screenshots/vendor_bill.png new file mode 100644 index 000000000..84df6fff7 Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/vendor_bill.png differ diff --git a/bill_digitization/static/description/assets/screenshots/wizard.png b/bill_digitization/static/description/assets/screenshots/wizard.png new file mode 100644 index 000000000..005cf2579 Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/wizard.png differ diff --git a/bill_digitization/static/description/banner.jpg b/bill_digitization/static/description/banner.jpg new file mode 100644 index 000000000..6690aba02 Binary files /dev/null and b/bill_digitization/static/description/banner.jpg differ diff --git a/bill_digitization/static/description/icon.png b/bill_digitization/static/description/icon.png new file mode 100644 index 000000000..b87e9830f Binary files /dev/null and b/bill_digitization/static/description/icon.png differ diff --git a/bill_digitization/static/description/index.html b/bill_digitization/static/description/index.html new file mode 100755 index 000000000..bdb752c3f --- /dev/null +++ b/bill_digitization/static/description/index.html @@ -0,0 +1,664 @@ +
+ +
+ +
+
+ Community +
+
+
+ + +
+
+
+ +

+ Bill Digitization

+

+ Creating Vendor Bill from Scanned Document

+
+ + +
+
+
+ + +
+
+ +
+

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ Bill Digitization allows user to create vendor bill from scanned + documents. + User can read .jpg, .jpeg and .png scanned files. +
+
+ + + +
+
+ +
+

+ Configuration +

+
+
+
+ Need to install the following python packages + 1. PIL (pip3 install PIL) + 2. pytesseract (pip3 install pytesseract) + 3. tesseract-ocr (sudo apt-get install tesseract-ocr) +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ +
+ Boolean Field on Configuration Settings to Choose Digitization Need +
+
+
+ +
+ A Button on Vendor Bill Tree View to Read Documents +
+
+
+ +
+ A View that Shows the Vendor Bill with All the Fetched Data +
+
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+
+

+ Option to Enable Digitization

+

+ This allows the user to choose digitization.

+ +
+
+

+ Digitization Button

+

+ Button to read scanned documents.

+ +
+
+

+ Digitization Wizard

+

+ A wizard that allows to read document.

+ +
+
+

+ Sample Bill

+

+ Sample bill

+ +
+
+

+ Vendor Bill

+

+ Vendor bill with scanned document data

+ +
+
+

+ (The example format for scanned document is added in the + module.)

+
+
+
+ + + +
+
+

Suggested Products

+
+ +
+
+ + + +
+
+ +
+

+ Our Services +

+
+
+
+
+
+ +
+
+ Odoo + Customization
+
+
+
+ +
+
+ Odoo + Implementation
+
+
+
+ +
+
+ Odoo + Support
+
+
+
+ +
+
+ Hire + Odoo + Developer
+
+
+
+ +
+
+ Odoo + Integration
+
+
+
+ +
+
+ Odoo + Migration
+
+
+
+ +
+
+ Odoo + Consultancy
+
+
+
+ +
+
+ Odoo + Implementation
+
+
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+ +
+

+ Our + Industries +

+
+
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+
+
+ + + +
+
+ +
+

+ Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+ +91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ diff --git a/bill_digitization/static/src/js/digitize_button.js b/bill_digitization/static/src/js/digitize_button.js new file mode 100644 index 000000000..2436adc15 --- /dev/null +++ b/bill_digitization/static/src/js/digitize_button.js @@ -0,0 +1,36 @@ +/** @odoo-module */ +import { ListController } from '@web/views/list/list_controller'; +import { patch } from "@web/core/utils/patch"; +const { useState } = owl; +var rpc = require('web.rpc'); +var core = require('web.core'); +var _t = core._t; + +patch(ListController.prototype, "DigitizeList", { + /* Making button visibility false in default */ + async setup(){ + this.state = useState({ + button_state : false + }) + this._super(); + /* Getting the value of the field */ + const digitizeBillParam = await rpc.query({ + model: 'ir.config_parameter', + method: 'get_param', + args: ['bill_digitization.digitize_bill'], + }); + this.state.button_state = digitizeBillParam + }, + /* Opening a wizard on button click */ + onClickDigitize() { + this.actionService.doAction({ + name: _t("Upload Bill"), + type: "ir.actions.act_window", + res_model: "digitize.bill", + view_type : 'form', + view_mode : 'form', + views: [[false, "form"]], + target: 'new', + }); + }, +}) diff --git a/bill_digitization/static/src/xml/digitize_button.xml b/bill_digitization/static/src/xml/digitize_button.xml new file mode 100644 index 000000000..12c6b8234 --- /dev/null +++ b/bill_digitization/static/src/xml/digitize_button.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/bill_digitization/views/res_config_settings_views.xml b/bill_digitization/views/res_config_settings_views.xml new file mode 100644 index 000000000..e0b116141 --- /dev/null +++ b/bill_digitization/views/res_config_settings_views.xml @@ -0,0 +1,28 @@ + + + + + res.config.settings.view.form.inherit.bill.digitization + res.config.settings + + + +
+
+ +
+
+
+
+
+
+
+
diff --git a/bill_digitization/wizard/__init__.py b/bill_digitization/wizard/__init__.py new file mode 100644 index 000000000..9f3010ba9 --- /dev/null +++ b/bill_digitization/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Sruthi Renjith (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import digitize_bill diff --git a/bill_digitization/wizard/digitize_bill.py b/bill_digitization/wizard/digitize_bill.py new file mode 100644 index 000000000..2a6c84878 --- /dev/null +++ b/bill_digitization/wizard/digitize_bill.py @@ -0,0 +1,395 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Sruthi Renjith (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +import io +import pytesseract +import re +from PIL import Image +from odoo import Command, fields, models, _ +from odoo.exceptions import ValidationError + + +class DigitizeBill(models.TransientModel): + """ To read documents and to convert into vendor bills """ + _name = "digitize.bill" + _description = "Digitize Bill" + + bill = fields.Binary(string="Document", required=True, + help="Choose a scanned document") + file_name = fields.Char(string="File Name", help="Name of the file") + + def record_lines(self, product_lines_newline_name_qty_price_amount, + product_lines_name_qty_amount, + product_lines_qty_name_amount, + product_lines_name_qty_price_amount1, + product_lines_name_price_qty_amount_with_dollar, + product_lines_name_price_qty_amount, + product_lines_name_amount, + product_lines_name_qty_price_amount2, + product_lines_double_line_name, + product_lines_code_name, + product_lines_quantity_part, + product_lines_vendor_bill_pattern, + product_lines_quantity_price_amount_pattern, + product_lines_quantity_price_amount_pattern2, + product_line_name_with_extra_line): + """ Function to extract bill data from text read by pytesseract """ + products = [] + price = [] + subtotal = [] + quantity = [] + if (product_lines_newline_name_qty_price_amount or + product_lines_name_qty_price_amount1 or + product_lines_name_qty_price_amount2): + if product_lines_name_qty_price_amount1: + product_lines_newline_name_qty_price_amount = ( + product_lines_name_qty_price_amount1) + if product_lines_name_qty_price_amount2: + product_lines_newline_name_qty_price_amount = ( + product_lines_name_qty_price_amount2) + # Fetching products and create new ones + products = [self.env['product.product'].search( + [('name', '=', line[0])], limit=1) or + self.env['product.product'].create( + {'name': line[0]}) + for line in + product_lines_newline_name_qty_price_amount] + # Creating lists for prices and subtotals + price = [line[2] for line in + product_lines_newline_name_qty_price_amount] + subtotal = [line[3] for line in + product_lines_newline_name_qty_price_amount] + elif product_lines_name_qty_amount: + # Fetching products and create new ones + products = [ + self.env['product.product'].search([('name', '=', line[0])], + limit=1) or + self.env['product.product'].create({'name': line[0]}) + for line in product_lines_name_qty_amount] + # Calculating unit prices + price = [ + float(line[2]) / float(line[1]) if float(line[1]) != 0 else 0 + for line in product_lines_name_qty_amount] + # Creating a list for subtotals + subtotal = [line[2] for line in product_lines_name_qty_amount] + elif product_lines_qty_name_amount: + # Fetching products and create new ones + products = [ + self.env['product.product'].search([('name', '=', line[1])], + limit=1) or + self.env['product.product'].create({'name': line[1]}) + for line in product_lines_qty_name_amount] + # Calculating unit prices + price = [ + float(line[2]) / float(line[0]) if float(line[0]) != 0 else 0 + for line in product_lines_qty_name_amount] + # Creating a list for subtotals + subtotal = [line[2] for line in product_lines_qty_name_amount] + elif (product_lines_name_price_qty_amount_with_dollar or + product_lines_name_price_qty_amount): + if product_lines_name_price_qty_amount: + product_lines_name_price_qty_amount_with_dollar = ( + product_lines_name_price_qty_amount) + # Fetching products and create new ones + products = [ + self.env['product.product'].search([('name', '=', line[0])], + limit=1) or + self.env['product.product'].create({'name': line[0]}) + for line in product_lines_name_price_qty_amount_with_dollar] + # Extracting item prices and amounts + price = [line[1].replace('$', '') if '$' in line[1] else line[1] + for line in + product_lines_name_price_qty_amount_with_dollar] + subtotal = [line[3].replace('$', '') if '$' in line[3] else line[3] + for line in + product_lines_name_price_qty_amount_with_dollar] + elif product_lines_name_amount: + # Fetching products and create new ones + products = [ + self.env['product.product'].search([('name', '=', line[0])], + limit=1) or + self.env['product.product'].create({'name': line[0]}) + for line in product_lines_name_amount] + # Extracting item amounts and create a list for subtotals + subtotal = [line[1].replace('$', '') if '$' in line[1] else line[1] + for line in product_lines_name_amount] + elif product_lines_code_name: + name_list_one = [] + if product_line_name_with_extra_line: + for code, name in product_line_name_with_extra_line: + product_info = f"{code} {name}" + name_list_one.append(product_info) + names = [item.strip() for item in + product_lines_code_name[0].split('\n') if item.strip()] + if name_list_one and len(name_list_one) > len(names): + names = name_list_one + if product_lines_quantity_part: + order_lines = [line.strip() for line in + product_lines_quantity_part[0].split('\n') if + line.strip()] + elif product_lines_quantity_price_amount_pattern: + order_lines = [line.strip() for line in + product_lines_quantity_price_amount_pattern[ + 0].split('\n') if + line.strip()] + elif product_lines_quantity_price_amount_pattern2: + order_lines = [line.strip() for line in + product_lines_quantity_price_amount_pattern2[ + 0].split('\n') if + line.strip()] + else: + order_lines = [] + # Create the 'products' list + products = [ + self.env['product.product'].search([('name', '=', name)], + limit=1) or + self.env['product.product'].create({'name': name}) + for name in names] + # Creating the unit price list + price = [float(line.split()[1].replace(',', '')) if line else 0 for + line in order_lines] + # Calculating and Creating the 'subtotal' list + subtotal = [float(line.split()[1].replace(',', '')) * float( + line.split()[0]) if line else 0 for line in order_lines] + # Creating the quantity list + quantity = [float(line.split()[0]) if line else 0 for line in + order_lines] + elif product_lines_vendor_bill_pattern: + products = [ + self.env['product.product'].search([('name', '=', item[0])], + limit=1) or + self.env['product.product'].create({'name': item[0]}) + for item in product_lines_vendor_bill_pattern] + quantity = [float(item[1]) for item in + product_lines_vendor_bill_pattern] + price = [float(item[2]) for item in + product_lines_vendor_bill_pattern] + subtotal = [float(item[2]) * float(item[1]) for item in + product_lines_vendor_bill_pattern] + if product_lines_double_line_name: + for line in product_lines_double_line_name: + product_name = line[0] + ' ' + line[1] + product = self.env['product.product'].search( + [('name', '=', product_name)], limit=1) + if not product: + product = self.env['product.product'].create({ + 'name': product_name + }) + products.append(product) + if '$' in line[5]: + line[5] = line[5].replace('$', '') + subtotal.append(line[5]) + item_price = line[4].replace('$', '') if '$' in line[4] else \ + line[4] + price.append(item_price) + if bool(quantity): + # Looping lists to create product line values + move_line_vals = [ + (0, 0, { + 'product_id': product.id, + 'name': 'Outside Bill', + 'price_unit': price_amount, + 'price_subtotal': total_amount, + 'quantity': qty, + 'tax_ids': [Command.set([])], + 'move_id': self.id, + }) + for product, price_amount, total_amount, qty in + zip(products, price, subtotal, quantity) + ] + elif bool(price): + # Looping three lists to create product line values + move_line_vals = [ + (0, 0, { + 'product_id': product.id, + 'name': 'Outside Bill', + 'price_unit': price_amount, + 'price_subtotal': total_amount, + 'tax_ids': [Command.set([])], + 'move_id': self.id, + }) + for product, price_amount, total_amount in + zip(products, price, subtotal) + ] + else: + move_line_vals = [ + (0, 0, { + 'product_id': product.id, + 'name': 'Outside Bill', + 'price_subtotal': total_amount, + 'tax_ids': [Command.set([])], + 'move_id': self.id, + }) + for product, total_amount in zip(products, subtotal) + ] + return move_line_vals + + def create_record(self, text): + """ Function to create vendor bill """ + # Different patterns or regular expressions to identify the data + # from the text + newline_name_qty_price_amount = \ + r'\n([A-Za-z ]+) (\d+) (\d+\.\d{2}) (\d+\.\d{2})' + name_qty_amount = r'\n([A-Za-z ]+) (\d+) (\d+\.\d{2})' + qty_name_amount = r'\n(\d+) ([A-Za-z ]+) (\d+\.\d{2})' + name_qty_price_amount1 = r'\s*([A-Za-z() \d]+) (\d+) (\d+) (\d+)' + name_price_qty_amount_with_dollar = \ + r'\n(\$?\w+(?: \w+)*) (\$[\d.]+) (\d+) (\$[\d.]+)' + name_price_qty_amount = \ + r'\n(\$?\w+(?: \w+)*) (\[\d.]+) (\d+) (\[\d.]+)' + name_amount = r'\n(\$?\w+(?: \w+)*) (\d+\.\d{2})' + name_qty_price_amount2 = r"([\w\s]+)\s+(\d+)\s+(\d+)\s+\$(\d+)" + double_line_name = \ + r'([\w\s]+)\s([\w\s]+)\s*([\w\s]+)\s*(\d+)\s*(\$\d+' \ + r'\.\d{2})\s*(\d+\.\d{2})' + code_name = r'Description\n([\s\S]*?)(?=\n\n)' + quantity_price_pattern = r'Quantity Unit Price Taxes\n([\s\S]*?)(?=\n\n)' + vendor_bill_pattern = r'\[[A-Z0-9-]+\] (.+?) (\d+\.\d+) (\d+\.\d+) (\d+\.\d+%?) \$ (\d+\.\d+)' + quantity_price_amount_pattern = r'Quantity Unit Price Taxes Amount\n((?:\d+\.\d+\s+\d+\.\d+\s+\d+\.\d+% \$\s+\d+\.\d+\n)+)' + quantity_price_amount_pattern2 = r'Quantity Unit Price Taxes Amount([\s\S]*?)(?:Untaxed Amount|Tax|Total|$)' + name_with_extra_line = r'\[([A-Z0-9-]+)\] (.+)' + + # Pattern to match date and bill number from the text + date_pattern = r'\d{1,2}/\d{1,2}/\d{2,4}' + bill_no_pattern = r'Bill\sNo\.: (\d{4})' + # Pattern to match the year format of date + # (two digit or four digit format) + year_pattern = re.compile(r'\d{2}') + # Matching each pattern with the text and fetching the matching + # data from it + try: + product_lines_newline_name_qty_price_amount = re.findall( + newline_name_qty_price_amount, text) + product_lines_name_qty_amount = re.findall(name_qty_amount, text) + product_lines_qty_name_amount = re.findall(qty_name_amount, text) + product_lines_name_qty_price_amount1 = re.findall( + name_qty_price_amount1, text) + product_lines_name_price_qty_amount_with_dollar = re.findall( + name_price_qty_amount_with_dollar, + text) + product_lines_name_price_qty_amount = re.findall( + name_price_qty_amount, text) + product_lines_name_amount = re.findall(name_amount, text) + product_lines_name_qty_price_amount2 = re.findall( + name_qty_price_amount2, text) + product_lines_double_line_name = re.findall(double_line_name, text) + date_match = re.search(date_pattern, text) + bill_no_match = re.search(bill_no_pattern, text) + product_lines_code_name = re.findall(code_name, text) + product_lines_quantity_part = re.findall( + quantity_price_pattern, text) + product_lines_vendor_bill_pattern = re.findall( + vendor_bill_pattern, text) + product_lines_quantity_price_amount_pattern = re.findall( + quantity_price_amount_pattern, text) + product_lines_quantity_price_amount_pattern2 = re.findall( + quantity_price_amount_pattern2, text) + product_line_name_with_extra_line = re.findall( + name_with_extra_line, text) + except Exception: + raise ValidationError(_("Cannot find the pattern")) + date_object = '' + if date_match: + # Reading the date value if the date pattern match any data + date_value = date_match.group() + match = year_pattern.search(date_value) + if date_value == '%d/%m/%y' or date_value == '%d/%m/%Y': + date_object = fields.datetime.strptime( + date_value, '%d/%m/%y') if match and len( + date_value.split('/')[ + -1]) == 2 else fields.datetime.strptime( + date_value, '%d/%m/%Y') + elif date_value == '%m/%d/%y' or date_value == '%m/%d/%Y': + date_object = fields.datetime.strptime( + date_value, '%m/%d/%y') if match and len( + date_value.split('/')[ + -1]) == 2 else fields.datetime.strptime( + date_value, '%m/%d/%Y') + date = date_object.strftime( + '%Y-%m-%d') if date_object else fields.Date.today() + else: + date = fields.Date.today() + # Fetching the bill number if te pattern matches + bill_no = bill_no_match.group(1) if bill_no_match else '' + # Calling the function to get the product lines of the bill + move_line_vals = self.record_lines( + product_lines_newline_name_qty_price_amount, + product_lines_name_qty_amount, + product_lines_qty_name_amount, + product_lines_name_qty_price_amount1, + product_lines_name_price_qty_amount_with_dollar, + product_lines_name_price_qty_amount, + product_lines_name_amount, product_lines_name_qty_price_amount2, + product_lines_double_line_name, + product_lines_code_name, + product_lines_quantity_part, + product_lines_vendor_bill_pattern, + product_lines_quantity_price_amount_pattern, + product_lines_quantity_price_amount_pattern2, + product_line_name_with_extra_line) + # After getting all the data, creating a record in the + # vendor bill + bill_record = self.env['account.move'].create([{ + 'move_type': 'in_invoice', + 'ref': bill_no, + 'date': date, + 'invoice_date': date, + 'invoice_line_ids': move_line_vals, + }]) + return bill_record + + def action_add_document(self): + """ Function that reading the file in the format .jpg, .jpeg and .png + and converting into text using OCR python package """ + try: + file_attachment = self.env["ir.attachment"].search( + ['|', ('res_field', '!=', False), ('res_field', '=', False), + ('res_id', '=', self.id), + ('res_model', '=', 'digitize.bill')], + limit=1) + file_path = file_attachment._full_path(file_attachment.store_fname) + with open(file_path, mode='rb') as file: + binary_data = file.read() + img = Image.open(io.BytesIO(binary_data)) + # Resizing the image to improve the clarity + resized_img = img.resize((img.width * 2, img.height * 2), + resample=Image.BICUBIC) + except Exception: + raise ValidationError(_("Cannot identify data")) + # Converting the image into text using OCR python package + # pytesseract + try: + text = pytesseract.image_to_string(resized_img) + except Exception: + raise ValidationError(_("Data cannot read")) + # Calling the function to create vendor bill + bill_record = self.create_record(text) + # Opening the vendor bill using its id + return { + 'name': "Invoice", + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'account.move', + 'res_id': bill_record.id, + 'view_id': self.env.ref('account.view_move_form').id, + 'target': 'current', + } diff --git a/bill_digitization/wizard/digitize_bill_views.xml b/bill_digitization/wizard/digitize_bill_views.xml new file mode 100644 index 000000000..2e513d72d --- /dev/null +++ b/bill_digitization/wizard/digitize_bill_views.xml @@ -0,0 +1,36 @@ + + + + + digitize.bill.view.form + digitize.bill + +
+ +

Upload images or pdf file format
+

+ + + + + + +
+
+
+
+
+
+ + + Digitize Bill + ir.actions.act_window + digitize.bill + form + + new + +