diff --git a/account_statement_import_online/__manifest__.py b/account_statement_import_online/__manifest__.py index 329629fb..f4fd54c8 100644 --- a/account_statement_import_online/__manifest__.py +++ b/account_statement_import_online/__manifest__.py @@ -21,6 +21,7 @@ "security/ir.model.access.csv", "security/online_bank_statement_provider.xml", "wizards/online_bank_statement_pull_wizard.xml", + "views/actions.xml", "views/account_journal.xml", "views/online_bank_statement_provider.xml", ], diff --git a/account_statement_import_online/i18n/account_statement_import_online.pot b/account_statement_import_online/i18n/account_statement_import_online.pot index 4bb755e0..60e0036d 100644 --- a/account_statement_import_online/i18n/account_statement_import_online.pot +++ b/account_statement_import_online/i18n/account_statement_import_online.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -34,6 +34,11 @@ msgstr "" msgid "Api Base" msgstr "" +#. module: account_statement_import_online +#: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_provider_form +msgid "Archived" +msgstr "" + #. module: account_statement_import_online #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__message_attachment_count msgid "Attachment Count" @@ -107,11 +112,7 @@ msgid "Day(s)" msgstr "" #. module: account_statement_import_online -#: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_provider_form -msgid "Details" -msgstr "" - -#. module: account_statement_import_online +#: model:ir.model.fields,field_description:account_statement_import_online.field_account_journal__display_name #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__display_name #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__display_name msgid "Display Name" @@ -140,12 +141,18 @@ msgstr "" msgid "Followers (Partners)" msgstr "" +#. module: account_statement_import_online +#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__date_since +msgid "From" +msgstr "" + #. module: account_statement_import_online #: model:ir.model.fields.selection,name:account_statement_import_online.selection__online_bank_statement_provider__interval_type__hours msgid "Hour(s)" msgstr "" #. module: account_statement_import_online +#: model:ir.model.fields,field_description:account_statement_import_online.field_account_journal__id #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__id #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__id msgid "ID" @@ -198,6 +205,7 @@ msgid "Key" msgstr "" #. module: account_statement_import_online +#: model:ir.model.fields,field_description:account_statement_import_online.field_account_journal____last_update #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider____last_update #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard____last_update msgid "Last Modified on" @@ -294,32 +302,30 @@ msgstr "" #. module: account_statement_import_online #: model:ir.model,name:account_statement_import_online.model_online_bank_statement_provider -#: model:ir.model.fields,field_description:account_statement_import_online.field_account_statement_import_journal_creation__online_bank_statement_provider #: model:ir.model.fields,field_description:account_statement_import_online.field_account_journal__online_bank_statement_provider #: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_provider_form msgid "Online Bank Statement Provider" msgstr "" #. module: account_statement_import_online +#: model:ir.actions.act_window,name:account_statement_import_online.online_bank_statement_provider_action +#: model:ir.ui.menu,name:account_statement_import_online.online_bank_statement_provider_menu #: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_provider_filter msgid "Online Bank Statement Providers" msgstr "" #. module: account_statement_import_online -#: code:addons/account_statement_import_online/models/account_journal.py:0 #: model:ir.model,name:account_statement_import_online.model_online_bank_statement_pull_wizard -#, python-format msgid "Online Bank Statement Pull Wizard" msgstr "" #. module: account_statement_import_online -#: model_terms:ir.ui.view,arch_db:account_statement_import_online.view_account_bank_journal_form #: model_terms:ir.ui.view,arch_db:account_statement_import_online.view_account_journal_form msgid "Online Bank Statements (OCA)" msgstr "" #. module: account_statement_import_online -#: model:ir.actions.server,name:account_statement_import_online.action_online_bank_statements_pull_wizard +#: model:ir.actions.act_window,name:account_statement_import_online.action_online_bank_statements_pull_wizard msgid "Online Bank Statements Pull Wizard" msgstr "" @@ -344,7 +350,6 @@ msgid "Password" msgstr "" #. module: account_statement_import_online -#: model_terms:ir.ui.view,arch_db:account_statement_import_online.view_account_bank_journal_form #: model_terms:ir.ui.view,arch_db:account_statement_import_online.view_account_journal_form msgid "Provider" msgstr "" @@ -359,6 +364,11 @@ msgstr "" msgid "Pull" msgstr "" +#. module: account_statement_import_online +#: model_terms:ir.ui.view,arch_db:account_statement_import_online.view_account_journal_form +msgid "Pull Online Bank Statement" +msgstr "" + #. module: account_statement_import_online #: model:ir.actions.server,name:account_statement_import_online.ir_cron_account_pull_online_bank_statements_ir_actions_server #: model:ir.cron,cron_name:account_statement_import_online.ir_cron_account_pull_online_bank_statements @@ -391,28 +401,30 @@ msgstr "" msgid "Scheduled update interval must be greater than zero!" msgstr "" +#. module: account_statement_import_online +#: model:ir.model.fields,help:account_statement_import_online.field_account_journal__online_bank_statement_provider_id +msgid "" +"Select the actual instance of a configured provider (a record).\n" +"Selecting a type of provider will automatically create a provider record linked to this journal." +msgstr "" + +#. module: account_statement_import_online +#: model:ir.model.fields,help:account_statement_import_online.field_account_journal__online_bank_statement_provider +msgid "Select the type of service provider (a model)" +msgstr "" + #. module: account_statement_import_online #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__service +#: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_provider_filter msgid "Service" msgstr "" -#. module: account_statement_import_online -#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__date_since -msgid "Since" -msgstr "" - -#. module: account_statement_import_online -#: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_pull_wizard_form -msgid "Since (at least)" -msgstr "" - #. module: account_statement_import_online #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__statement_creation_mode msgid "Statement Creation Mode" msgstr "" #. module: account_statement_import_online -#: model:ir.model.fields,field_description:account_statement_import_online.field_account_statement_import_journal_creation__online_bank_statement_provider_id #: model:ir.model.fields,field_description:account_statement_import_online.field_account_journal__online_bank_statement_provider_id msgid "Statement Provider" msgstr "" @@ -434,6 +446,11 @@ msgid "" "statement." msgstr "" +#. module: account_statement_import_online +#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__date_until +msgid "To" +msgstr "" + #. module: account_statement_import_online #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__message_unread msgid "Unread Messages" @@ -444,16 +461,6 @@ msgstr "" msgid "Unread Messages Counter" msgstr "" -#. module: account_statement_import_online -#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__date_until -msgid "Until" -msgstr "" - -#. module: account_statement_import_online -#: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_pull_wizard_form -msgid "Until (at least)" -msgstr "" - #. module: account_statement_import_online #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__update_schedule msgid "Update Schedule" diff --git a/account_statement_import_online/models/account_journal.py b/account_statement_import_online/models/account_journal.py index df89ee1b..edd9857a 100644 --- a/account_statement_import_online/models/account_journal.py +++ b/account_statement_import_online/models/account_journal.py @@ -16,12 +16,16 @@ class AccountJournal(models.Model): selection=lambda self: self.env[ "account.journal" ]._selection_online_bank_statement_provider(), + help="Select the type of service provider (a model)", ) online_bank_statement_provider_id = fields.Many2one( string="Statement Provider", comodel_name="online.bank.statement.provider", ondelete="restrict", copy=False, + help="Select the actual instance of a configured provider (a record).\n" + "Selecting a type of provider will automatically create a provider" + " record linked to this journal.", ) def __get_bank_statements_available_sources(self): @@ -37,12 +41,14 @@ class AccountJournal(models.Model): @api.model def values_online_bank_statement_provider(self): + """Return values for provider type selection in the form view.""" res = self.env["online.bank.statement.provider"]._get_available_services() if self.user_has_groups("base.group_no_one"): res += [("dummy", "Dummy")] return res def _update_online_bank_statement_provider_id(self): + """Keep provider synchronized with journal.""" OnlineBankStatementProvider = self.env["online.bank.statement.provider"] for journal in self.filtered("id"): provider_id = journal.online_bank_statement_provider_id diff --git a/account_statement_import_online/models/online_bank_statement_provider.py b/account_statement_import_online/models/online_bank_statement_provider.py index 63ffb315..58675e39 100644 --- a/account_statement_import_online/models/online_bank_statement_provider.py +++ b/account_statement_import_online/models/online_bank_statement_provider.py @@ -24,7 +24,7 @@ class OnlineBankStatementProvider(models.Model): _description = "Online Bank Statement Provider" company_id = fields.Many2one(related="journal_id.company_id", store=True) - active = fields.Boolean() + active = fields.Boolean(default=True) name = fields.Char(string="Name", compute="_compute_name", store=True) journal_id = fields.Many2one( comodel_name="account.journal", @@ -122,12 +122,11 @@ class OnlineBankStatementProvider(models.Model): def values_service(self): return self._get_available_services() - @api.depends("service") + @api.depends("service", "journal_id.name") def _compute_name(self): + """We can have multiple providers/journals for the same service.""" for provider in self: - provider.name = list( - filter(lambda x: x[0] == provider.service, self._selection_service()) - )[0][1] + provider.name = " ".join([provider.journal_id.name, provider.service]) @api.depends("active", "interval_type", "interval_number") def _compute_update_schedule(self): diff --git a/account_statement_import_online/tests/__init__.py b/account_statement_import_online/tests/__init__.py index c631b1f0..9f86f27b 100644 --- a/account_statement_import_online/tests/__init__.py +++ b/account_statement_import_online/tests/__init__.py @@ -1,3 +1,4 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import test_account_bank_statement_import_online +from . import test_account_journal diff --git a/account_statement_import_online/tests/test_account_bank_statement_import_online.py b/account_statement_import_online/tests/test_account_bank_statement_import_online.py index e16ce1f3..70f722e6 100644 --- a/account_statement_import_online/tests/test_account_bank_statement_import_online.py +++ b/account_statement_import_online/tests/test_account_bank_statement_import_online.py @@ -48,8 +48,15 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): journal_form.save() self.assertTrue(journal.online_bank_statement_provider_id) + save_provider_id = journal.online_bank_statement_provider_id.id journal.unlink() - self.assertFalse(self.OnlineBankStatementProvider.search([])) + self.assertFalse( + self.OnlineBankStatementProvider.search( + [ + ("id", "=", save_provider_id), + ] + ) + ) def test_source_change_cleanup(self): journal = self.AccountJournal.create( @@ -61,13 +68,25 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): journal_form.save() self.assertTrue(journal.online_bank_statement_provider_id) + save_provider_id = journal.online_bank_statement_provider_id.id + + # Stuff should not change when doing unrelated write. + journal.write({"code": "BIGBANK"}) + self.assertTrue(journal.online_bank_statement_provider_id) + self.assertEqual(journal.online_bank_statement_provider_id.id, save_provider_id) with common.Form(journal) as journal_form: journal_form.bank_statements_source = "undefined" journal_form.save() self.assertFalse(journal.online_bank_statement_provider_id) - self.assertFalse(self.OnlineBankStatementProvider.search([])) + self.assertFalse( + self.OnlineBankStatementProvider.search( + [ + ("id", "=", save_provider_id), + ] + ) + ) def test_pull_mode_daily(self): journal = self.AccountJournal.create( @@ -396,13 +415,13 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): "online_bank_statement_provider": "dummy", } ) - wizard = self.OnlineBankStatementPullWizard.with_context( + vals = self.OnlineBankStatementPullWizard.with_context( active_model="account.journal", active_id=journal.id - ).create( - {"date_since": self.now - relativedelta(hours=1), "date_until": self.now} - ) + ).default_get(fields_list=["provider_ids"]) + vals["date_since"] = self.now - relativedelta(hours=1) + vals["date_until"] = self.now + wizard = self.OnlineBankStatementPullWizard.create(vals) self.assertTrue(wizard.provider_ids) - wizard.action_pull() self.assertTrue( self.AccountBankStatement.search([("journal_id", "=", journal.id)]) diff --git a/account_statement_import_online/tests/test_account_journal.py b/account_statement_import_online/tests/test_account_journal.py new file mode 100644 index 00000000..476200a5 --- /dev/null +++ b/account_statement_import_online/tests/test_account_journal.py @@ -0,0 +1,22 @@ +# Copyright 2021 Therp BV (https://therp.nl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from mock import patch + +from odoo.tests import common + + +class TestAccountJournal(common.TransactionCase): + """Test some functions adde d to account.journal model.""" + + def setUp(self): + super().setUp() + self.AccountJournal = self.env["account.journal"] + + def test_values_online_bank_statement_provider(self): + """Check method to retrieve provider types.""" + # Make sure the users seems to have the group_no_one. + with patch.object( + self.AccountJournal.__class__, "user_has_groups", return_value=True + ): + values = self.AccountJournal.values_online_bank_statement_provider() + self.assertIn("dummy", [entry[0] for entry in values]) diff --git a/account_statement_import_online/views/account_journal.xml b/account_statement_import_online/views/account_journal.xml index fe319292..f2b7bf83 100644 --- a/account_statement_import_online/views/account_journal.xml +++ b/account_statement_import_online/views/account_journal.xml @@ -2,6 +2,7 @@ @@ -48,27 +49,15 @@ -
+
- - Online Bank Statements Pull Wizard - online.bank.statement.pull.wizard - new - form - - list - - diff --git a/account_statement_import_online/views/actions.xml b/account_statement_import_online/views/actions.xml new file mode 100644 index 00000000..ce24fa50 --- /dev/null +++ b/account_statement_import_online/views/actions.xml @@ -0,0 +1,19 @@ + + + + + Online Bank Statements Pull Wizard + online.bank.statement.pull.wizard + new + form + + list + + + diff --git a/account_statement_import_online/views/online_bank_statement_provider.xml b/account_statement_import_online/views/online_bank_statement_provider.xml index de3f26aa..b81c8a47 100644 --- a/account_statement_import_online/views/online_bank_statement_provider.xml +++ b/account_statement_import_online/views/online_bank_statement_provider.xml @@ -17,7 +17,7 @@ domain="[('active', '=', False)]" /> -
- - + @@ -61,25 +61,25 @@ name="company_id" groups="base.group_multi_company" /> - - + - + - - - + + +
@@ -88,12 +88,12 @@
- + - - Online Bank Statement Providers - online.bank.statement.provider - tree,form + + Online Bank Statement Providers + online.bank.statement.provider + tree,form
- - - + + +