diff --git a/account_statement_import_online_ofx/README.rst b/account_statement_import_online_ofx/README.rst index 8c9836b6..8e63a8fe 100644 --- a/account_statement_import_online_ofx/README.rst +++ b/account_statement_import_online_ofx/README.rst @@ -1,11 +1,36 @@ -================================== +=========================== Online Bank Statements: OFX -================================== +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e6ebad00d6c39c92584c6ee76b5deae328742e8a81229971ce4ca37d2f1e4cb1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github + :target: https://github.com/OCA/bank-statement-import/tree/16.0/account_statement_import_online_ofx + :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-16-0/bank-statement-import-16-0-account_statement_import_online_ofx + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| This module provides online bank statements from Open Financial Exchange (OFX) institutions. You can set-up your own provider, or import a list of supported providers. -https://ofxhome.com/ is used as a data source, currently over 300 institutions are supported. - +https://ofxhome.com/ is used as a data source, currently over 300 institutions are supported. **Table of contents** @@ -17,13 +42,15 @@ Configuration To configure online bank statements provider: -#. Go to *Invoicing > Configuration > Journals* -#. Open bank journal to configure and edit it -#. Set *Bank Feeds* to *Online* -#. Select *OFX* as online bank statements provider in - *Online Bank Statements (OCA)* section -#. Save the bank journal -#. Click on provider and configure provider-specific settings. +#. Go to *Invoicing > Configuration > Online Bank Statement Providers* +#. Create a provider and configure provider-specific settings. + +If you want to allow empty bank statements to be created every time the +information is pulled, you can check the option "Allow empty statements" +at the provider configuration level. + +**NOTE**: To access these features, user needs to belong to +*Show Full Accounting Features* group. Usage ===== @@ -35,17 +62,13 @@ To pull historical bank statements: #. Launch *Actions > Online Bank Statements Pull Wizard* #. Configure date interval and click *Pull* -Known issues / Roadmap -====================== - - 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 `_. +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. @@ -63,3 +86,20 @@ Contributors * `ForgeFlow `__ * Jasmin Solanki + +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. + +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_online_ofx/__manifest__.py b/account_statement_import_online_ofx/__manifest__.py index b81154df..cdf2c210 100644 --- a/account_statement_import_online_ofx/__manifest__.py +++ b/account_statement_import_online_ofx/__manifest__.py @@ -3,13 +3,15 @@ { "name": "Online Bank Statements: OFX", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/bank-statement-import", "license": "AGPL-3", "category": "Accounting", "summary": "Online bank statements for OFX", - "depends": ["account_statement_import_online"], + "depends": [ + "account_statement_import_online", + ], "external_dependencies": {"python": ["ofxtools", "ofxparse"]}, "data": [ "security/ir.model.access.csv", diff --git a/account_statement_import_online_ofx/models/online_bank_statement_provider_ofx.py b/account_statement_import_online_ofx/models/online_bank_statement_provider_ofx.py index 0c5d7ea6..5be103dc 100644 --- a/account_statement_import_online_ofx/models/online_bank_statement_provider_ofx.py +++ b/account_statement_import_online_ofx/models/online_bank_statement_provider_ofx.py @@ -97,7 +97,7 @@ class OnlineBankStatementProviderOFX(models.Model): except Exception as e: raise UserError( _("The following problem occurred during import.\n\n %s") % str(e) - ) + ) from e return lines, {} @api.model @@ -118,14 +118,17 @@ class OnlineBankStatementProviderOFX(models.Model): def import_ofx_institutions(self): OfxInstitution = self.env["ofx.institution"] try: - with requests.get("http://www.ofxhome.com/api.php?all=yes") as f: + with requests.get( + "http://www.ofxhome.com/api.php?all=yes", timeout=30 + ) as f: response = f.text institute_list = { fi.get("id").strip(): fi.get("name").strip() for fi in ET.fromstring(response) } except Exception as e: - raise UserError(_(e)) + raise UserError(_(e)) from e + for ofxhome_id, name in institute_list.items(): institute = OfxInstitution.search([("ofxhome_id", "=", ofxhome_id)]) vals = { @@ -145,19 +148,27 @@ class OnlineBankStatementProviderOFX(models.Model): data, statement_date_since, statement_date_until ) if self.service == "OFX": - AccountBankStatement = self.env["account.bank.statement"] - statement_date = self._get_statement_date( + unfiltered_lines, statement_values = data + if not unfiltered_lines: + unfiltered_lines = [] + if not statement_values: + statement_values = {} + statement_values["name"] = self.make_statement_name(statement_date_since) + filtered_lines = self._get_statement_filtered_lines( + unfiltered_lines, + statement_values, statement_date_since, statement_date_until, ) - statement = AccountBankStatement.search( - [ - ("journal_id", "=", self.journal_id.id), - ("state", "=", "open"), - ("date", "=", statement_date), - ], - limit=1, - ) + if not filtered_lines: + return + if filtered_lines: + statement_values.update( + {"line_ids": [[0, False, line] for line in filtered_lines]} + ) + self._update_statement_balances(statement_values) + statement = self._statement_create_or_write(statement_values) + self._journal_set_statement_source() if not statement.line_ids: statement.unlink() return res diff --git a/account_statement_import_online_ofx/readme/CONFIGURE.rst b/account_statement_import_online_ofx/readme/CONFIGURE.rst index d5439af2..562e6f22 100644 --- a/account_statement_import_online_ofx/readme/CONFIGURE.rst +++ b/account_statement_import_online_ofx/readme/CONFIGURE.rst @@ -1,9 +1,11 @@ To configure online bank statements provider: -#. Go to *Invoicing > Configuration > Journals* -#. Open bank journal to configure and edit it -#. Set *Bank Feeds* to *Online* -#. Select *OFX* as online bank statements provider in - *Online Bank Statements (OCA)* section -#. Save the bank journal -#. Click on provider and configure provider-specific settings. +#. Go to *Invoicing > Configuration > Online Bank Statement Providers* +#. Create a provider and configure provider-specific settings. + +If you want to allow empty bank statements to be created every time the +information is pulled, you can check the option "Allow empty statements" +at the provider configuration level. + +**NOTE**: To access these features, user needs to belong to +*Show Full Accounting Features* group. diff --git a/account_statement_import_online_ofx/static/description/index.html b/account_statement_import_online_ofx/static/description/index.html new file mode 100644 index 00000000..5e8e3a4e --- /dev/null +++ b/account_statement_import_online_ofx/static/description/index.html @@ -0,0 +1,451 @@ + + + + + + +Online Bank Statements: OFX + + + +
+

Online Bank Statements: OFX

+ + +

Beta License: AGPL-3 OCA/bank-statement-import Translate me on Weblate Try me on Runboat

+

This module provides online bank statements from Open Financial Exchange (OFX) institutions. +You can set-up your own provider, or import a list of supported providers. +https://ofxhome.com/ is used as a data source, currently over 300 institutions are supported.

+

Table of contents

+ +
+

Configuration

+

To configure online bank statements provider:

+
    +
  1. Go to Invoicing > Configuration > Online Bank Statement Providers
  2. +
  3. Create a provider and configure provider-specific settings.
  4. +
+

If you want to allow empty bank statements to be created every time the +information is pulled, you can check the option “Allow empty statements” +at the provider configuration level.

+

NOTE: To access these features, user needs to belong to +Show Full Accounting Features group.

+
+
+

Usage

+

To pull historical bank statements:

+
    +
  1. Go to Invoicing > Configuration > Journals
  2. +
  3. Select specific bank accounts
  4. +
  5. Launch Actions > Online Bank Statements Pull Wizard
  6. +
  7. Configure date interval and click Pull
  8. +
+
+
+

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

+
    +
  • ForgeFlow
  • +
+
+
+

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.

+

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_online_ofx/tests/test_account_statement_import_online_ofx.py b/account_statement_import_online_ofx/tests/test_account_statement_import_online_ofx.py index 655a6473..c0c2dcf5 100644 --- a/account_statement_import_online_ofx/tests/test_account_statement_import_online_ofx.py +++ b/account_statement_import_online_ofx/tests/test_account_statement_import_online_ofx.py @@ -34,17 +34,11 @@ class TestAccountBankAccountStatementImportOnlineOFX(common.TransactionCase): ) def test_import_online_ofx(self): - # Create bank journal - journal = self.AccountJournal.create( - { - "name": "Bank", - "type": "bank", - "code": "BANK", - "bank_statements_source": "online", - "online_bank_statement_provider": "OFX", - } - ) - provider = journal.online_bank_statement_provider_id + + provider_model = self.env["online.bank.statement.provider"] + active_id = self.env.context.get("active_id") + provider = provider_model.browse(active_id) + # Create OFX institution line in OFX provider self.OfxInstitutionLine.create( { diff --git a/account_statement_import_online_ofx/wizards/online_bank_statement_pull_wizard.py b/account_statement_import_online_ofx/wizards/online_bank_statement_pull_wizard.py index 3d0b8a18..af85425e 100644 --- a/account_statement_import_online_ofx/wizards/online_bank_statement_pull_wizard.py +++ b/account_statement_import_online_ofx/wizards/online_bank_statement_pull_wizard.py @@ -13,18 +13,16 @@ class OnlineBankStatementPullWizard(models.TransientModel): column1="wizard_id", column2="institution_line_id", relation="ofx_institution_line_pull_wizard_rel", - domain="[('provider_id','in',provider_ids)]", ) + is_ofx_provider = fields.Boolean() - @api.onchange("provider_ids") - def onchange_provider_ids(self): - for rec in self: - rec.is_ofx_provider = False - for provider in rec.provider_ids: - if provider.service == "OFX": - rec.is_ofx_provider = True - break + @api.onchange("date_since") + def _compute_is_ofx_provider(self): + provider_model = self.env["online.bank.statement.provider"] + active_id = self.env.context.get("active_id") + provider = provider_model.browse(active_id) + self.is_ofx_provider = provider.service == "OFX" def action_pull(self): return super( diff --git a/account_statement_import_online_ofx/wizards/online_bank_statement_pull_wizard.xml b/account_statement_import_online_ofx/wizards/online_bank_statement_pull_wizard.xml index ade08671..45a5483a 100644 --- a/account_statement_import_online_ofx/wizards/online_bank_statement_pull_wizard.xml +++ b/account_statement_import_online_ofx/wizards/online_bank_statement_pull_wizard.xml @@ -8,7 +8,7 @@ ref="account_statement_import_online.online_bank_statement_pull_wizard_form" /> - +