diff --git a/account_statement_import_base/README.rst b/account_statement_import_base/README.rst new file mode 100644 index 000000000..d02427b0b --- /dev/null +++ b/account_statement_import_base/README.rst @@ -0,0 +1,90 @@ +===================================== +Base module for Bank Statement Import +===================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9fa09d431b4c7e1698f01c7fd2250709e7c51a8ad373c7b6bdefe84c3ead0541 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.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-17-0/bank-statement-import-17-0-account_statement_import_base + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=17.0 + :alt: Try me on Runboat + +|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 to smash 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 000000000..0650744f6 --- /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 000000000..2ad24db78 --- /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": "17.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 000000000..11fd0fa0a --- /dev/null +++ b/account_statement_import_base/i18n/account_statement_import_base.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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__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__raw_data +#: model_terms:ir.ui.view,arch_db:account_statement_import_base.account_bank_statement_line_form +msgid "Raw Data" +msgstr "" diff --git a/account_statement_import_base/i18n/ca.po b/account_statement_import_base/i18n/ca.po new file mode 100644 index 000000000..4d745827c --- /dev/null +++ b/account_statement_import_base/i18n/ca.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-18 18:35+0000\n" +"Last-Translator: pere-aquarian \n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\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 "Una transacció de compte bancari només es pot importar una vegada!" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_bank_statement_line +msgid "Bank Statement Line" +msgstr "Línia d'extracte bancari" + +#. 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 "Importar ID" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_journal +msgid "Journal" +msgstr "Diari" + +#. 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.account_bank_statement_line_form +msgid "Raw Data" +msgstr "Dades de línia" diff --git a/account_statement_import_base/i18n/es.po b/account_statement_import_base/i18n/es.po new file mode 100644 index 000000000..fa6c1b6ba --- /dev/null +++ b/account_statement_import_base/i18n/es.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-02 14:10+0000\n" +"Last-Translator: gelo joga Rodríguez \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\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 "¡Una transacción bancaria sólo se puede importar una vez!" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_bank_statement_line +msgid "Bank Statement Line" +msgstr "Línea de extracto bancario" + +#. 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 "ID importación" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_journal +msgid "Journal" +msgstr "Diario" + +#. 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.account_bank_statement_line_form +msgid "Raw Data" +msgstr "Datos sin procesar" diff --git a/account_statement_import_base/i18n/fr.po b/account_statement_import_base/i18n/fr.po new file mode 100644 index 000000000..b9f54e5e6 --- /dev/null +++ b/account_statement_import_base/i18n/fr.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-08 14:08+0000\n" +"Last-Translator: Alexis de Lattre \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\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 "Une transaction bancaire ne peut être importée qu'une seule fois !" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_bank_statement_line +msgid "Bank Statement Line" +msgstr "Ligne de relevé de compte" + +#. 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 "Identifiant d'import" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_journal +msgid "Journal" +msgstr "Journal" + +#. 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.account_bank_statement_line_form +msgid "Raw Data" +msgstr "Données brutes" diff --git a/account_statement_import_base/i18n/hr.po b/account_statement_import_base/i18n/hr.po new file mode 100644 index 000000000..ff931aff2 --- /dev/null +++ b/account_statement_import_base/i18n/hr.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-02 14:10+0000\n" +"Last-Translator: Bole \n" +"Language-Team: none\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 4.17\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 "Transakcija po bankovnom računu može biti uvežena samo jednom!" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_bank_statement_line +msgid "Bank Statement Line" +msgstr "Stavka izvoda" + +#. 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 "ID Uvoza" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_journal +msgid "Journal" +msgstr "Dnevnik" + +#. 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.account_bank_statement_line_form +msgid "Raw Data" +msgstr "Sirovi podaci" diff --git a/account_statement_import_base/i18n/pt_BR.po b/account_statement_import_base/i18n/pt_BR.po new file mode 100644 index 000000000..a7352273d --- /dev/null +++ b/account_statement_import_base/i18n/pt_BR.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-27 16:10+0000\n" +"Last-Translator: Adriano Prado \n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\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 "Uma transação de conta bancária pode ser importada apenas uma vez!" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_bank_statement_line +msgid "Bank Statement Line" +msgstr "Linha de Extrato Bancário" + +#. 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 "ID Importação" + +#. module: account_statement_import_base +#: model:ir.model,name:account_statement_import_base.model_account_journal +msgid "Journal" +msgstr "Diário" + +#. 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.account_bank_statement_line_form +msgid "Raw Data" +msgstr "Dados Raw" diff --git a/account_statement_import_base/models/__init__.py b/account_statement_import_base/models/__init__.py new file mode 100644 index 000000000..4c252e458 --- /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 000000000..0058331f9 --- /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 000000000..3080fe74b --- /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/pyproject.toml b/account_statement_import_base/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/account_statement_import_base/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_statement_import_base/readme/CONTRIBUTORS.md b/account_statement_import_base/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..b61afe5d0 --- /dev/null +++ b/account_statement_import_base/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Alexis de Lattre \<\> diff --git a/account_statement_import_base/readme/DESCRIPTION.md b/account_statement_import_base/readme/DESCRIPTION.md new file mode 100644 index 000000000..b147dead2 --- /dev/null +++ b/account_statement_import_base/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +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 000000000..3a0328b51 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 000000000..d0e637a54 --- /dev/null +++ b/account_statement_import_base/static/description/index.html @@ -0,0 +1,428 @@ + + + + +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 Runboat

+

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 to smash 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 000000000..d32bc3442 --- /dev/null +++ b/account_statement_import_base/views/account_bank_statement_line.xml @@ -0,0 +1,27 @@ + + + + + + account.bank.statement.line + + + + + + + + + + + + + +