mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[IMP] account_statement_import_online: don't import empty statements.
This commit is contained in:
committed by
Carolina Fernandez
parent
fe7adc1bdf
commit
071b4e9004
@@ -56,6 +56,10 @@ or, alternatively:
|
|||||||
#. Save the bank account
|
#. Save the bank account
|
||||||
#. Click on provider and configure provider-specific settings.
|
#. Click on 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
|
**NOTE**: To access these features, user needs to belong to
|
||||||
*Show Full Accounting Features* group.
|
*Show Full Accounting Features* group.
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Online Bank Statements",
|
"name": "Online Bank Statements",
|
||||||
"version": "14.0.1.0.0",
|
"version": "14.0.2.0.0",
|
||||||
"author": "CorporateHub, Odoo Community Association (OCA)",
|
"author": "CorporateHub, Odoo Community Association (OCA)",
|
||||||
"maintainers": ["alexey-pelykh"],
|
"maintainers": ["alexey-pelykh"],
|
||||||
"website": "https://github.com/OCA/bank-statement-import",
|
"website": "https://github.com/OCA/bank-statement-import",
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ msgstr ""
|
|||||||
msgid "Active"
|
msgid "Active"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_statement_import_online
|
||||||
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__allow_empty_statements
|
||||||
|
msgid "Allow empty statements"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__api_base
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__api_base
|
||||||
msgid "Api Base"
|
msgid "Api Base"
|
||||||
|
|||||||
@@ -32,11 +32,21 @@ msgstr "Actie vereist"
|
|||||||
msgid "Active"
|
msgid "Active"
|
||||||
msgstr "Actief"
|
msgstr "Actief"
|
||||||
|
|
||||||
|
#. module: account_statement_import_online
|
||||||
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__allow_empty_statements
|
||||||
|
msgid "Allow empty statements"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__api_base
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__api_base
|
||||||
msgid "Api Base"
|
msgid "Api Base"
|
||||||
msgstr "Api Base"
|
msgstr "Api Base"
|
||||||
|
|
||||||
|
#. 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
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__message_attachment_count
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__message_attachment_count
|
||||||
msgid "Attachment Count"
|
msgid "Attachment Count"
|
||||||
@@ -110,11 +120,7 @@ msgid "Day(s)"
|
|||||||
msgstr "Dag(en)"
|
msgstr "Dag(en)"
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. module: account_statement_import_online
|
||||||
#: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_provider_form
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_account_journal__display_name
|
||||||
msgid "Details"
|
|
||||||
msgstr "Details"
|
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
|
||||||
#: 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_provider__display_name
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__display_name
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__display_name
|
||||||
msgid "Display Name"
|
msgid "Display Name"
|
||||||
@@ -124,8 +130,8 @@ msgstr "Weergavenaam"
|
|||||||
#: code:addons/account_statement_import_online/models/online_bank_statement_provider.py:0
|
#: code:addons/account_statement_import_online/models/online_bank_statement_provider.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"Failed to obtain statement data for period since %s until %s: %s. See server"
|
"Failed to obtain statement data for period since %s until %s: %s. See server "
|
||||||
" logs for more details."
|
"logs for more details."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Kon de afschriften niet verkrijgen voor de periode van %s tot %s:%s. Bekijk "
|
"Kon de afschriften niet verkrijgen voor de periode van %s tot %s:%s. Bekijk "
|
||||||
"de error log van de server voor details."
|
"de error log van de server voor details."
|
||||||
@@ -145,12 +151,18 @@ msgstr "Volgers (Kanalen)"
|
|||||||
msgid "Followers (Partners)"
|
msgid "Followers (Partners)"
|
||||||
msgstr "Volgers (Partners)"
|
msgstr "Volgers (Partners)"
|
||||||
|
|
||||||
|
#. 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
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model.fields.selection,name:account_statement_import_online.selection__online_bank_statement_provider__interval_type__hours
|
#: model:ir.model.fields.selection,name:account_statement_import_online.selection__online_bank_statement_provider__interval_type__hours
|
||||||
msgid "Hour(s)"
|
msgid "Hour(s)"
|
||||||
msgstr "Uur/Uren"
|
msgstr "Uur/Uren"
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. 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_provider__id
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__id
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard__id
|
||||||
msgid "ID"
|
msgid "ID"
|
||||||
@@ -203,6 +215,7 @@ msgid "Key"
|
|||||||
msgstr "Sleutel"
|
msgstr "Sleutel"
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. 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_provider____last_update
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard____last_update
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_pull_wizard____last_update
|
||||||
msgid "Last Modified on"
|
msgid "Last Modified on"
|
||||||
@@ -299,32 +312,30 @@ msgstr "Online (OCA)"
|
|||||||
|
|
||||||
#. module: account_statement_import_online
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model,name:account_statement_import_online.model_online_bank_statement_provider
|
#: 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: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
|
#: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_provider_form
|
||||||
msgid "Online Bank Statement Provider"
|
msgid "Online Bank Statement Provider"
|
||||||
msgstr "Online Bank afschrift Aanbieder"
|
msgstr "Online Bank afschrift Aanbieder"
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. 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
|
#: model_terms:ir.ui.view,arch_db:account_statement_import_online.online_bank_statement_provider_filter
|
||||||
msgid "Online Bank Statement Providers"
|
msgid "Online Bank Statement Providers"
|
||||||
msgstr "Online Bank afschrift Aanbieders"
|
msgstr "Online Bank afschrift Aanbieders"
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. 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
|
#: model:ir.model,name:account_statement_import_online.model_online_bank_statement_pull_wizard
|
||||||
#, python-format
|
|
||||||
msgid "Online Bank Statement Pull Wizard"
|
msgid "Online Bank Statement Pull Wizard"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. 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
|
#: model_terms:ir.ui.view,arch_db:account_statement_import_online.view_account_journal_form
|
||||||
msgid "Online Bank Statements (OCA)"
|
msgid "Online Bank Statements (OCA)"
|
||||||
msgstr "Online Bank Afschriften (OCA)"
|
msgstr "Online Bank Afschriften (OCA)"
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. 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"
|
msgid "Online Bank Statements Pull Wizard"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -350,7 +361,6 @@ msgid "Password"
|
|||||||
msgstr "Wachtwoord"
|
msgstr "Wachtwoord"
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. 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
|
#: model_terms:ir.ui.view,arch_db:account_statement_import_online.view_account_journal_form
|
||||||
msgid "Provider"
|
msgid "Provider"
|
||||||
msgstr "Leverancier"
|
msgstr "Leverancier"
|
||||||
@@ -365,6 +375,11 @@ msgstr "Leveranciers"
|
|||||||
msgid "Pull"
|
msgid "Pull"
|
||||||
msgstr "Opvragen"
|
msgstr "Opvragen"
|
||||||
|
|
||||||
|
#. 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
|
#. 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.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
|
#: model:ir.cron,cron_name:account_statement_import_online.ir_cron_account_pull_online_bank_statements
|
||||||
@@ -397,28 +412,31 @@ msgstr "Opvraag interval"
|
|||||||
msgid "Scheduled update interval must be greater than zero!"
|
msgid "Scheduled update interval must be greater than zero!"
|
||||||
msgstr "Planningsinterval moet groter zijn dan 0!"
|
msgstr "Planningsinterval moet groter zijn dan 0!"
|
||||||
|
|
||||||
|
#. 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
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__service
|
#: 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"
|
msgid "Service"
|
||||||
msgstr "Service"
|
msgstr "Service"
|
||||||
|
|
||||||
#. 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 "sinds"
|
|
||||||
|
|
||||||
#. 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 "sinds (ten minste)"
|
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__statement_creation_mode
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__statement_creation_mode
|
||||||
msgid "Statement Creation Mode"
|
msgid "Statement Creation Mode"
|
||||||
msgstr "Bankafschrift creatie modus"
|
msgstr "Bankafschrift creatie modus"
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. 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
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_account_journal__online_bank_statement_provider_id
|
||||||
msgid "Statement Provider"
|
msgid "Statement Provider"
|
||||||
msgstr "Afschrift leverancier"
|
msgstr "Afschrift leverancier"
|
||||||
@@ -440,6 +458,11 @@ msgid ""
|
|||||||
"statement."
|
"statement."
|
||||||
msgstr ""
|
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
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__message_unread
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__message_unread
|
||||||
msgid "Unread Messages"
|
msgid "Unread Messages"
|
||||||
@@ -450,16 +473,6 @@ msgstr "Ongelezen berichten"
|
|||||||
msgid "Unread Messages Counter"
|
msgid "Unread Messages Counter"
|
||||||
msgstr "Aantal ongelezen berichten"
|
msgstr "Aantal ongelezen berichten"
|
||||||
|
|
||||||
#. 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 "Tot"
|
|
||||||
|
|
||||||
#. 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 "Tot (ten minste)"
|
|
||||||
|
|
||||||
#. module: account_statement_import_online
|
#. module: account_statement_import_online
|
||||||
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__update_schedule
|
#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__update_schedule
|
||||||
msgid "Update Schedule"
|
msgid "Update Schedule"
|
||||||
@@ -489,3 +502,18 @@ msgstr "Weken"
|
|||||||
#: model:ir.model.fields.selection,name:account_statement_import_online.selection__online_bank_statement_provider__statement_creation_mode__weekly
|
#: model:ir.model.fields.selection,name:account_statement_import_online.selection__online_bank_statement_provider__statement_creation_mode__weekly
|
||||||
msgid "Weekly statements"
|
msgid "Weekly statements"
|
||||||
msgstr "Weekelijkse afschriften"
|
msgstr "Weekelijkse afschriften"
|
||||||
|
|
||||||
|
#~ msgid "Details"
|
||||||
|
#~ msgstr "Details"
|
||||||
|
|
||||||
|
#~ msgid "Since"
|
||||||
|
#~ msgstr "sinds"
|
||||||
|
|
||||||
|
#~ msgid "Since (at least)"
|
||||||
|
#~ msgstr "sinds (ten minste)"
|
||||||
|
|
||||||
|
#~ msgid "Until"
|
||||||
|
#~ msgstr "Tot"
|
||||||
|
|
||||||
|
#~ msgid "Until (at least)"
|
||||||
|
#~ msgstr "Tot (ten minste)"
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ class OnlineBankStatementProvider(models.Model):
|
|||||||
certificate_public_key = fields.Text()
|
certificate_public_key = fields.Text()
|
||||||
certificate_private_key = fields.Text()
|
certificate_private_key = fields.Text()
|
||||||
certificate_chain = fields.Text()
|
certificate_chain = fields.Text()
|
||||||
|
allow_empty_statements = fields.Boolean(string="Allow empty statements")
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
(
|
(
|
||||||
@@ -204,6 +205,8 @@ class OnlineBankStatementProvider(models.Model):
|
|||||||
)
|
)
|
||||||
if not data:
|
if not data:
|
||||||
data = ([], {})
|
data = ([], {})
|
||||||
|
if not data[0] and not data[1] and not self.allow_empty_statements:
|
||||||
|
return
|
||||||
lines_data, statement_values = data
|
lines_data, statement_values = data
|
||||||
if not lines_data:
|
if not lines_data:
|
||||||
lines_data = []
|
lines_data = []
|
||||||
|
|||||||
@@ -19,5 +19,9 @@ or, alternatively:
|
|||||||
#. Save the bank account
|
#. Save the bank account
|
||||||
#. Click on provider and configure provider-specific settings.
|
#. Click on 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
|
**NOTE**: To access these features, user needs to belong to
|
||||||
*Show Full Accounting Features* group.
|
*Show Full Accounting Features* group.
|
||||||
|
|||||||
@@ -406,6 +406,9 @@ section</li>
|
|||||||
<li>Save the bank account</li>
|
<li>Save the bank account</li>
|
||||||
<li>Click on provider and configure provider-specific settings.</li>
|
<li>Click on provider and configure provider-specific settings.</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
<p>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.</p>
|
||||||
<p><strong>NOTE</strong>: To access these features, user needs to belong to
|
<p><strong>NOTE</strong>: To access these features, user needs to belong to
|
||||||
<em>Show Full Accounting Features</em> group.</p>
|
<em>Show Full Accounting Features</em> group.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
|
from unittest import mock
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
@@ -12,6 +13,12 @@ from odoo import fields
|
|||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
from odoo.tools import mute_logger
|
from odoo.tools import mute_logger
|
||||||
|
|
||||||
|
mock_obtain_statement_data = (
|
||||||
|
"odoo.addons.account_statement_import_online.tests."
|
||||||
|
+ "online_bank_statement_provider_dummy.OnlineBankStatementProviderDummy."
|
||||||
|
+ "_obtain_statement_data"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestAccountBankAccountStatementImportOnline(common.TransactionCase):
|
class TestAccountBankAccountStatementImportOnline(common.TransactionCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -657,3 +664,94 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase):
|
|||||||
self.assertEqual(lines[1].date, date(2020, 4, 18))
|
self.assertEqual(lines[1].date, date(2020, 4, 18))
|
||||||
self.assertEqual(lines[2].date, date(2020, 4, 18))
|
self.assertEqual(lines[2].date, date(2020, 4, 18))
|
||||||
self.assertEqual(lines[3].date, date(2020, 4, 18))
|
self.assertEqual(lines[3].date, date(2020, 4, 18))
|
||||||
|
|
||||||
|
def _get_statement_line_data(self, statement_date):
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"payment_ref": "payment",
|
||||||
|
"amount": 100,
|
||||||
|
"date": statement_date,
|
||||||
|
"unique_import_id": str(statement_date),
|
||||||
|
"partner_name": "John Doe",
|
||||||
|
"account_number": "XX00 0000 0000 0000",
|
||||||
|
}
|
||||||
|
], {}
|
||||||
|
|
||||||
|
def test_dont_create_empty_statements(self):
|
||||||
|
"""Test the default behavior of not creating empty bank
|
||||||
|
statements ('Allow empty statements' field is uncheck at the
|
||||||
|
provider level.).
|
||||||
|
"""
|
||||||
|
journal = self.AccountJournal.create(
|
||||||
|
{
|
||||||
|
"name": "Bank",
|
||||||
|
"type": "bank",
|
||||||
|
"code": "BANK",
|
||||||
|
"bank_statements_source": "online",
|
||||||
|
"online_bank_statement_provider": "dummy",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
provider = journal.online_bank_statement_provider_id
|
||||||
|
provider.active = True
|
||||||
|
provider.statement_creation_mode = "daily"
|
||||||
|
with mock.patch(mock_obtain_statement_data) as mock_data:
|
||||||
|
mock_data.side_effect = [
|
||||||
|
self._get_statement_line_data(date(2021, 8, 10)),
|
||||||
|
([], {}), # August 8th, doesn't have statement
|
||||||
|
([], {}), # August 9th, doesn't have statement
|
||||||
|
self._get_statement_line_data(date(2021, 8, 13)),
|
||||||
|
]
|
||||||
|
provider._pull(datetime(2021, 8, 10), datetime(2021, 8, 14))
|
||||||
|
statements = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
|
self.assertEqual(len(statements), 2)
|
||||||
|
self.assertEqual(statements[1].balance_start, 0)
|
||||||
|
self.assertEqual(statements[1].balance_end_real, 100)
|
||||||
|
self.assertEqual(len(statements[1].line_ids), 1)
|
||||||
|
self.assertEqual(statements[0].balance_start, 100)
|
||||||
|
self.assertEqual(statements[0].balance_end_real, 200)
|
||||||
|
self.assertEqual(len(statements[0].line_ids), 1)
|
||||||
|
|
||||||
|
def test_create_empty_statements(self):
|
||||||
|
"""Test creating empty bank statements
|
||||||
|
('Allow empty statements' field is check at the provider level).
|
||||||
|
"""
|
||||||
|
journal = self.AccountJournal.create(
|
||||||
|
{
|
||||||
|
"name": "Bank",
|
||||||
|
"type": "bank",
|
||||||
|
"code": "BANK",
|
||||||
|
"bank_statements_source": "online",
|
||||||
|
"online_bank_statement_provider": "dummy",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
provider = journal.online_bank_statement_provider_id
|
||||||
|
provider.active = True
|
||||||
|
provider.allow_empty_statements = True
|
||||||
|
provider.statement_creation_mode = "daily"
|
||||||
|
with mock.patch(mock_obtain_statement_data) as mock_data:
|
||||||
|
mock_data.side_effect = [
|
||||||
|
self._get_statement_line_data(date(2021, 8, 10)),
|
||||||
|
([], {}), # August 8th, doesn't have statement
|
||||||
|
([], {}), # August 9th, doesn't have statement
|
||||||
|
self._get_statement_line_data(date(2021, 8, 13)),
|
||||||
|
]
|
||||||
|
provider._pull(datetime(2021, 8, 10), datetime(2021, 8, 14))
|
||||||
|
statements = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
|
# 4 Statements: 2 with movements and 2 empty
|
||||||
|
self.assertEqual(len(statements), 4)
|
||||||
|
# With movement
|
||||||
|
self.assertEqual(statements[3].balance_start, 0)
|
||||||
|
self.assertEqual(statements[3].balance_end_real, 100)
|
||||||
|
self.assertEqual(len(statements[3].line_ids), 1)
|
||||||
|
# Empty
|
||||||
|
self.assertEqual(statements[2].balance_start, 100)
|
||||||
|
self.assertEqual(statements[2].balance_end_real, 100)
|
||||||
|
self.assertEqual(len(statements[2].line_ids), 0)
|
||||||
|
# Empty
|
||||||
|
self.assertEqual(statements[1].balance_start, 100)
|
||||||
|
self.assertEqual(statements[1].balance_end_real, 100)
|
||||||
|
self.assertEqual(len(statements[1].line_ids), 0)
|
||||||
|
# With movement
|
||||||
|
self.assertEqual(statements[0].balance_start, 100)
|
||||||
|
self.assertEqual(statements[0].balance_end_real, 200)
|
||||||
|
self.assertEqual(len(statements[0].line_ids), 1)
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
<group name="configuration" string="Configuration">
|
<group name="configuration" string="Configuration">
|
||||||
<field name="statement_creation_mode" />
|
<field name="statement_creation_mode" />
|
||||||
<field name="tz" />
|
<field name="tz" />
|
||||||
|
<field name="allow_empty_statements" />
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
|||||||
Reference in New Issue
Block a user