diff --git a/account_statement_import_base/README.rst b/account_statement_import_base/README.rst new file mode 100644 index 00000000..76b26025 --- /dev/null +++ b/account_statement_import_base/README.rst @@ -0,0 +1,84 @@ +===================================== +Base module for Bank Statement Import +===================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png + :target: https://odoo-community.org/page/development-status + :alt: Mature +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github + :target: https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_base + :alt: OCA/bank-statement-import +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/bank-statement-import-14-0/bank-statement-import-14-0-account_statement_import_base + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/174/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This is a technical module designed to share code between 2 other modules: + +* **account_statement_import** that allows to import bank statements from files, +* **account_statement_import_online** that allows to import bank statements from webservices/APIs. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Alexis de Lattre + +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-alexis-via| image:: https://github.com/alexis-via.png?size=40px + :target: https://github.com/alexis-via + :alt: alexis-via + +Current `maintainer `__: + +|maintainer-alexis-via| + +This module is part of the `OCA/bank-statement-import `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_statement_import_base/__init__.py b/account_statement_import_base/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/account_statement_import_base/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_statement_import_base/__manifest__.py b/account_statement_import_base/__manifest__.py new file mode 100644 index 00000000..d5d78b39 --- /dev/null +++ b/account_statement_import_base/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# Licence LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). + +{ + "name": "Base module for Bank Statement Import", + "category": "Accounting", + "version": "16.0.1.0.0", + "license": "LGPL-3", + "depends": ["account_statement_base"], + "author": "Akretion, Odoo Community Association (OCA)", + "maintainers": ["alexis-via"], + "development_status": "Mature", + "website": "https://github.com/OCA/bank-statement-import", + "data": [ + "views/account_bank_statement_line.xml", + ], + "installable": True, +} diff --git a/account_statement_import_base/i18n/account_statement_import_base.pot b/account_statement_import_base/i18n/account_statement_import_base.pot new file mode 100644 index 00000000..de4704d9 --- /dev/null +++ b/account_statement_import_base/i18n/account_statement_import_base.pot @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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: account_statement_import_base +#: model:ir.model.constraint,message:account_statement_import_base.constraint_account_bank_statement_line_unique_import_id +msgid "A bank account transaction can be imported only once!" +msgstr "" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_bank_statement_line +msgid "Bank Statement Line" +msgstr "" + +#. module: account_statement_import_base +#: model:ir.model.fields,field_description:account_statement_import_base.field_account_bank_statement_line__display_name +#: model:ir.model.fields,field_description:account_statement_import_base.field_account_journal__display_name +msgid "Display Name" +msgstr "" + +#. module: account_statement_import_base +#: model:ir.model.fields,field_description:account_statement_import_base.field_account_bank_statement_line__id +#: model:ir.model.fields,field_description:account_statement_import_base.field_account_journal__id +msgid "ID" +msgstr "" + +#. module: account_statement_import_base +#: model:ir.model.fields,field_description:account_statement_import_base.field_account_bank_statement_line__unique_import_id +msgid "Import ID" +msgstr "" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_statement_import_base +#: model:ir.model.fields,field_description:account_statement_import_base.field_account_bank_statement_line____last_update +#: model:ir.model.fields,field_description:account_statement_import_base.field_account_journal____last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_statement_import_base +#: model_terms:ir.ui.view,arch_db:account_statement_import_base.view_bank_statement_line_form +msgid "Notes" +msgstr "" + +#. module: account_statement_import_base +#: model:ir.model.fields,field_description:account_statement_import_base.field_account_bank_statement_line__raw_data +#: model_terms:ir.ui.view,arch_db:account_statement_import_base.view_bank_statement_line_form +msgid "Raw Data" +msgstr "" + +#. module: account_statement_import_base +#: model_terms:ir.ui.view,arch_db:account_statement_import_base.view_bank_statement_line_form +msgid "Technical Information" +msgstr "" diff --git a/account_statement_import_base/models/__init__.py b/account_statement_import_base/models/__init__.py new file mode 100644 index 00000000..4c252e45 --- /dev/null +++ b/account_statement_import_base/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_bank_statement_line +from . import account_journal diff --git a/account_statement_import_base/models/account_bank_statement_line.py b/account_statement_import_base/models/account_bank_statement_line.py new file mode 100644 index 00000000..0058331f --- /dev/null +++ b/account_statement_import_base/models/account_bank_statement_line.py @@ -0,0 +1,22 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class AccountBankStatementLine(models.Model): + _inherit = "account.bank.statement.line" + + # Ensure transactions can be imported only once + # if the import format provides unique transaction IDs + unique_import_id = fields.Char(string="Import ID", readonly=True, copy=False) + raw_data = fields.Text(readonly=True, copy=False) + + _sql_constraints = [ + ( + "unique_import_id", + "unique(unique_import_id)", + "A bank account transaction can be imported only once!", + ) + ] diff --git a/account_statement_import_base/models/account_journal.py b/account_statement_import_base/models/account_journal.py new file mode 100644 index 00000000..3080fe74 --- /dev/null +++ b/account_statement_import_base/models/account_journal.py @@ -0,0 +1,69 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import api, models + +from odoo.addons.base.models.res_bank import sanitize_account_number + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + def _statement_line_import_speeddict(self): + """This method is designed to be inherited by reconciliation modules. + These modules can take advantage of this method to pre-fetch data + that will later be used for many statement lines (to avoid + searching data for each statement line). + The goal is to improve performances. + """ + self.ensure_one() + speeddict = {"account_number": {}} + partner_banks = self.env["res.partner.bank"].search_read( + [("company_id", "in", (False, self.company_id.id))], + ["acc_number", "partner_id"], + ) + for partner_bank in partner_banks: + speeddict["account_number"][partner_bank["acc_number"]] = { + "partner_id": partner_bank["partner_id"][0], + "partner_bank_id": partner_bank["id"], + } + return speeddict + + def _statement_line_import_update_hook(self, st_line_vals, speeddict): + """This method is designed to be inherited by reconciliation modules. + In this method you can: + - update the partner of the line by writing st_line_vals['partner_id'] + - set an automated counter-part via counterpart_account_id by writing + st_line_vals['counterpart_account_id'] + - do anythink you want with the statement line + """ + self.ensure_one() + if st_line_vals.get("account_number"): + st_line_vals["account_number"] = self._sanitize_bank_account_number( + st_line_vals["account_number"] + ) + if not st_line_vals.get("partner_id") and speeddict["account_number"].get( + st_line_vals["account_number"] + ): + st_line_vals.update( + speeddict["account_number"][st_line_vals["account_number"]] + ) + + def _statement_line_import_update_unique_import_id( + self, st_line_vals, account_number + ): + self.ensure_one() + if st_line_vals.get("unique_import_id"): + sanitized_acc_number = self._sanitize_bank_account_number(account_number) + st_line_vals["unique_import_id"] = ( + (sanitized_acc_number and sanitized_acc_number + "-" or "") + + str(self.id) + + "-" + + st_line_vals["unique_import_id"] + ) + + @api.model + def _sanitize_bank_account_number(self, account_number): + """Hook for extension""" + return sanitize_account_number(account_number) diff --git a/account_statement_import_base/readme/CONTRIBUTORS.rst b/account_statement_import_base/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..ff65d68c --- /dev/null +++ b/account_statement_import_base/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Alexis de Lattre diff --git a/account_statement_import_base/readme/DESCRIPTION.rst b/account_statement_import_base/readme/DESCRIPTION.rst new file mode 100644 index 00000000..4bf07f19 --- /dev/null +++ b/account_statement_import_base/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This is a technical module designed to share code between 2 other modules: + +* **account_statement_import** that allows to import bank statements from files, +* **account_statement_import_online** that allows to import bank statements from webservices/APIs. diff --git a/account_statement_import_base/static/description/icon.png b/account_statement_import_base/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_statement_import_base/static/description/icon.png differ diff --git a/account_statement_import_base/static/description/index.html b/account_statement_import_base/static/description/index.html new file mode 100644 index 00000000..2dbc811c --- /dev/null +++ b/account_statement_import_base/static/description/index.html @@ -0,0 +1,425 @@ + + + + + + +Base module for Bank Statement Import + + + +
+

Base module for Bank Statement Import

+ + +

Mature License: LGPL-3 OCA/bank-statement-import Translate me on Weblate Try me on Runbot

+

This is a technical module designed to share code between 2 other modules:

+
    +
  • account_statement_import that allows to import bank statements from files,
  • +
  • account_statement_import_online that allows to import bank statements from webservices/APIs.
  • +
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

alexis-via

+

This module is part of the OCA/bank-statement-import project on GitHub.

+

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

+
+
+
+ + diff --git a/account_statement_import_base/views/account_bank_statement_line.xml b/account_statement_import_base/views/account_bank_statement_line.xml new file mode 100644 index 00000000..d32bc344 --- /dev/null +++ b/account_statement_import_base/views/account_bank_statement_line.xml @@ -0,0 +1,27 @@ + + + + + + account.bank.statement.line + + + + + + + + + + + + + + diff --git a/setup/account_statement_import_base/odoo/addons/account_statement_import_base b/setup/account_statement_import_base/odoo/addons/account_statement_import_base new file mode 120000 index 00000000..431b0bc9 --- /dev/null +++ b/setup/account_statement_import_base/odoo/addons/account_statement_import_base @@ -0,0 +1 @@ +../../../../account_statement_import_base \ No newline at end of file diff --git a/setup/account_statement_import_base/setup.py b/setup/account_statement_import_base/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_statement_import_base/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)