diff --git a/bill_digitization/README.rst b/bill_digitization/README.rst new file mode 100755 index 000000000..a4341f8c5 --- /dev/null +++ b/bill_digitization/README.rst @@ -0,0 +1,48 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg + :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +Bill Digitization +================= +Reading scanned documents with extension .jpg, .jpeg and .png and creating +vendor bills in odoo. + +Configuration +============= +- Install PIL, pytesseract +- Enable 'Digitize Bill' option from configuration settings + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +General Public License, Version 3 (LGPL v3). +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) + +Credits +------- +Developer: (V15) Sruthi Renjith, Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +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..80d687cd6 --- /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 LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL 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..c6656ef85 --- /dev/null +++ b/bill_digitization/__manifest__.py @@ -0,0 +1,58 @@ +# -*- 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 LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + 'name': 'Bill Digitization', + 'version': '15.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', + 'views/account_move_views.xml', + 'wizard/digitize_bill_views.xml'], + 'assets': { + 'web.assets_backend': [ + 'bill_digitization/static/src/js/digitize_button.js', + ], + 'web.assets_qweb': [ + 'bill_digitization/static/src/xml/digitize_button_templates.xml', + ], + }, + 'external_dependencies': { + 'python': ['PIL', 'pytesseract'] + }, + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-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..e9e81e8c3 --- /dev/null +++ b/bill_digitization/doc/RELEASE_NOTES.md @@ -0,0 +1,5 @@ +## Module +#### 26.11.2023 +#### Version 15.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..efb514175 --- /dev/null +++ b/bill_digitization/models/__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 LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import ir_http +from . import res_config_settings diff --git a/bill_digitization/models/ir_http.py b/bill_digitization/models/ir_http.py new file mode 100644 index 000000000..010791d15 --- /dev/null +++ b/bill_digitization/models/ir_http.py @@ -0,0 +1,36 @@ +# -*- 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 LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import models + + +class IrHttp(models.AbstractModel): + """ Class to get the button state in a session """ + _inherit = 'ir.http' + + def session_info(self): + """ Inheriting the ir.http model and super the session_info function + to use the value in JS """ + info = super(IrHttp, self).session_info() + info["button_state"] = True if self.env[ + 'ir.config_parameter'].get_param( + 'bill_digitization.digitize_bill') == 'True' else False + return info diff --git a/bill_digitization/models/res_config_settings.py b/bill_digitization/models/res_config_settings.py new file mode 100644 index 000000000..33dee1aa3 --- /dev/null +++ b/bill_digitization/models/res_config_settings.py @@ -0,0 +1,34 @@ +# -*- 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 LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """ Class to add a boolean field in configuration settings to enable + digitization """ + + _inherit = "res.config.settings" + + digitize_bill = fields.Boolean(config_parameter='bill_digitization.' + 'digitize_bill', + string="Digitize Bill", + help="Enable the option to digitize bill") 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/1.png b/bill_digitization/static/description/assets/modules/1.png new file mode 100644 index 000000000..b19bf9df7 Binary files /dev/null and b/bill_digitization/static/description/assets/modules/1.png differ diff --git a/bill_digitization/static/description/assets/modules/2.png b/bill_digitization/static/description/assets/modules/2.png new file mode 100644 index 000000000..6f11d9e4b Binary files /dev/null and b/bill_digitization/static/description/assets/modules/2.png differ diff --git a/bill_digitization/static/description/assets/modules/3.png b/bill_digitization/static/description/assets/modules/3.png new file mode 100644 index 000000000..1bae9eabe Binary files /dev/null and b/bill_digitization/static/description/assets/modules/3.png differ diff --git a/bill_digitization/static/description/assets/modules/4.png b/bill_digitization/static/description/assets/modules/4.png new file mode 100644 index 000000000..3932f4062 Binary files /dev/null and b/bill_digitization/static/description/assets/modules/4.png differ diff --git a/bill_digitization/static/description/assets/modules/5.png b/bill_digitization/static/description/assets/modules/5.png new file mode 100644 index 000000000..b50130c7d Binary files /dev/null and b/bill_digitization/static/description/assets/modules/5.png differ diff --git a/bill_digitization/static/description/assets/modules/6.png b/bill_digitization/static/description/assets/modules/6.png new file mode 100644 index 000000000..cdcba33eb Binary files /dev/null and b/bill_digitization/static/description/assets/modules/6.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..a57df7fbd 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..d8eee8629 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_bill.jpg b/bill_digitization/static/description/assets/screenshots/demo_bill.jpg new file mode 100644 index 000000000..784a45868 Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/demo_bill.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..58a9ba07e Binary files /dev/null and b/bill_digitization/static/description/assets/screenshots/hero.gif 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..d30a4ebde 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..4ec5e26e9 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..1a2b99105 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..91e6e8a7c 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..b64e3ae42 --- /dev/null +++ b/bill_digitization/static/description/index.html @@ -0,0 +1,660 @@ +
+ +
+ +
+
+ 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 +
+
+
+ +
+ 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.

+ +
+
+

+ Vendor Bill

+

+ Vendor bill with scanned document data

+ +
+
+

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

+
+
+
+ + + +
+
+ +
+

+ 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..4616c0127 --- /dev/null +++ b/bill_digitization/static/src/js/digitize_button.js @@ -0,0 +1,44 @@ +odoo.define('bill_digitization.tree_button', function (require) { + "use strict"; + var ListController = require('web.ListController'); + var ListView = require('web.ListView'); + var viewRegistry = require('web.view_registry'); + var rpc = require('web.rpc'); + const session = require('web.session'); + var TreeButton = ListController.extend({ + /* Assigning a default value to the button_state */ + state: { + button_state : false + }, + /* Retrieves the current value of the button state from the session. */ + get_button_value: function(){ + return session.button_state + }, + buttons_template: 'bill_digitization.buttons', + /* Click event to pop up a wizard */ + events: _.extend({}, ListController.prototype.events, { + 'click .open_wizard_action': '_OpenWizard', + }), + /* Function that calling upon clicking the button */ + _OpenWizard: function () { + var self = this; + self.do_action({ + type: 'ir.actions.act_window', + res_model: 'digitize.bill', + name :'Upload Bill', + view_mode: 'form', + view_type: 'form', + views: [[false, 'form']], + target: 'new', + res_id: false, + }); + }, + }); + /* Adding the button into specific view */ + var AccountMoveListView = ListView.extend({ + config: _.extend({}, ListView.prototype.config, { + Controller: TreeButton, + }), + }); + viewRegistry.add('button_in_tree', AccountMoveListView); + }); diff --git a/bill_digitization/static/src/xml/digitize_button_templates.xml b/bill_digitization/static/src/xml/digitize_button_templates.xml new file mode 100644 index 000000000..3b4d2eede --- /dev/null +++ b/bill_digitization/static/src/xml/digitize_button_templates.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/bill_digitization/views/account_move_views.xml b/bill_digitization/views/account_move_views.xml new file mode 100644 index 000000000..224d136f9 --- /dev/null +++ b/bill_digitization/views/account_move_views.xml @@ -0,0 +1,14 @@ + + + + + account.move.view.tree.inherit.bill.digitization + account.move + + + + button_in_tree + + + + 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..c32f3d852 --- /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..63c9e0244 --- /dev/null +++ b/bill_digitization/wizard/digitize_bill.py @@ -0,0 +1,383 @@ +# -*- 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): + """ Class to read bills and create vendor bill from it """ + _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_amount, + product_lines_name_price_qty_amount_with_dollar, + product_lines_name_price_qty_amount, + product_lines_name_amount, + product_lines_name_qty_price_dollar_amount, + 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_amount or \ + product_lines_name_qty_price_dollar_amount: + if product_lines_name_qty_price_amount: + product_lines_newline_name_qty_price_amount = \ + product_lines_name_qty_price_amount + if product_lines_name_qty_price_dollar_amount: + product_lines_newline_name_qty_price_amount = \ + product_lines_name_qty_price_dollar_amount + # Creating products and appending them to the products list + products = [ + self.env['product.product'].search([('name', '=', line[0])], + limit=1)[0] + if self.env['product.product'].search([('name', '=', line[0])], + limit=1) + else self.env['product.product'].create({'name': line[0]}) + for line in product_lines_newline_name_qty_price_amount + ] + # Extracting price and subtotal from each line and appending them + # to their respective lists + 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: + # Creating the 'products' list and calculate unit price + 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 the unit price and create the 'price' list + price = [ + float(line[2]) / float(line[1]) if float(line[1]) != 0 else 0 + for line in product_lines_name_qty_amount] + # Creating the 'subtotal' list + subtotal = [line[2] for line in product_lines_name_qty_amount] + elif product_lines_qty_name_amount: + # Create the 'products' list and calculate unit price + 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 the unit price and create the 'price' list + price = [ + float(line[2]) / float(line[0]) if float(line[0]) != 0 else 0 + for line in product_lines_qty_name_amount] + # Creating the 'subtotal' list + 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 + 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 + price = [line[1].replace('$', '') if '$' in line[1] else line[1] + for line in + product_lines_name_price_qty_amount_with_dollar] + # Extracting subtotal amounts + 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 + 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 subtotal amounts + 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] + 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: + # Fetching the product name, price and subtotal and appending + # into different lists for the patterns + # 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 = [ + { + '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 = [ + { + '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 = [ + { + '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_amount = 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_dollar_amount = 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)' + 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|$)' + vendor_bill_pattern = r'\[[A-Z0-9-]+\] (.+?) (\d+\.\d+) (\d+\.\d+) (\d+\.\d+%?) \$ (\d+\.\d+)' + 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_amount = re.findall( + name_qty_price_amount, 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_dollar_amount = re.findall( + name_qty_price_dollar_amount, text) + product_lines_double_line_name = re.findall(double_line_name, 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) + date_match = re.search(date_pattern, text) + bill_no_match = re.search(bill_no_pattern, 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_amount, + product_lines_name_price_qty_amount_with_dollar, + product_lines_name_price_qty_amount, + product_lines_name_amount, + product_lines_name_qty_price_dollar_amount, + 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 f: + binary_data = f.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..72996c5ed --- /dev/null +++ b/bill_digitization/wizard/digitize_bill_views.xml @@ -0,0 +1,41 @@ + + + + + digitize.bill.view.form + digitize.bill + +
+ +

+

+ Upload images or pdf file format +
+

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