mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[MIG] account_bank_statement_import_txt_xlsx: Migration to 14.0
[FIX] Mostly currency-related fixes [IMP] sample_statement_en test: add dates on description Co-authored-by: Marco Colombo <marco.colombo@gmail.com>
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from . import account_bank_statement_import_sheet_mapping
|
|
||||||
from . import account_bank_statement_import_sheet_parser
|
|
||||||
from . import account_bank_statement_import
|
|
||||||
from . import account_journal
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
This module allows you to import the any TXT/CSV or XLSX file in Odoo as bank
|
|
||||||
statements.
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
|
||||||
access_account_bank_statement_import_sheet_mapping_manager,account.bank.statement.import.sheet.mapping:account.group_account_manager,model_account_bank_statement_import_sheet_mapping,account.group_account_manager,1,1,1,1
|
|
||||||
access_account_bank_statement_import_sheet_mapping_user,account.bank.statement.import.sheet.mapping:account.group_account_user,model_account_bank_statement_import_sheet_mapping,account.group_account_user,1,0,0,0
|
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
"Date","Label","Currency","Amount","Amount Currency","Partner Name","Bank Account"
|
|
||||||
"12/15/2018","Your best supplier","USD","-33.50","0.0","John Doe","123456789"
|
|
||||||
"12/15/2018","Your payment","EUR","1,525.00","1,000.00","Azure Interior",""
|
|
||||||
|
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
==========================================
|
==================================
|
||||||
Account Bank Statement Import TXT/CSV/XLSX
|
Bank Statement TXT/CSV/XLSX Import
|
||||||
==========================================
|
==================================
|
||||||
|
|
||||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
@@ -14,18 +14,18 @@ Account Bank Statement Import TXT/CSV/XLSX
|
|||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github
|
.. |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/13.0/account_bank_statement_import_txt_xlsx
|
:target: https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_txt_xlsx
|
||||||
:alt: OCA/bank-statement-import
|
:alt: OCA/bank-statement-import
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||||
:target: https://translation.odoo-community.org/projects/bank-statement-import-13-0/bank-statement-import-13-0-account_bank_statement_import_txt_xlsx
|
:target: https://translation.odoo-community.org/projects/bank-statement-import-14-0/bank-statement-import-14-0-account_statement_import_txt_xlsx
|
||||||
:alt: Translate me on Weblate
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||||
:target: https://runbot.odoo-community.org/runbot/174/13.0
|
:target: https://runbot.odoo-community.org/runbot/174/14.0
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
|
|
||||||
This module allows you to import the any TXT/CSV or XLSX file in Odoo as bank
|
This module allows you to import any TXT/CSV or XLSX file in Odoo as bank
|
||||||
statements.
|
statements.
|
||||||
|
|
||||||
**Table of contents**
|
**Table of contents**
|
||||||
@@ -66,7 +66,7 @@ Bug Tracker
|
|||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-import/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-import/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
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
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_bank_statement_import_txt_xlsx%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_txt_xlsx%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
@@ -119,6 +119,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
|||||||
|
|
||||||
|maintainer-alexey-pelykh|
|
|maintainer-alexey-pelykh|
|
||||||
|
|
||||||
This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_txt_xlsx>`_ project on GitHub.
|
This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_txt_xlsx>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
@@ -3,9 +3,9 @@
|
|||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Account Bank Statement Import TXT/CSV/XLSX",
|
"name": "Bank Statement TXT/CSV/XLSX Import",
|
||||||
"summary": "Import TXT/CSV or XLSX files as Bank Statements in Odoo",
|
"summary": "Import TXT/CSV or XLSX files as Bank Statements in Odoo",
|
||||||
"version": "13.0.1.0.4",
|
"version": "14.0.1.0.0",
|
||||||
"category": "Accounting",
|
"category": "Accounting",
|
||||||
"website": "https://github.com/OCA/bank-statement-import",
|
"website": "https://github.com/OCA/bank-statement-import",
|
||||||
"author": "ForgeFlow, CorporateHub, Odoo Community Association (OCA)",
|
"author": "ForgeFlow, CorporateHub, Odoo Community Association (OCA)",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"depends": [
|
"depends": [
|
||||||
"account_bank_statement_import",
|
"account_statement_import",
|
||||||
"multi_step_wizard",
|
"multi_step_wizard",
|
||||||
"web_widget_dropdown_dynamic",
|
"web_widget_dropdown_dynamic",
|
||||||
],
|
],
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
"data": [
|
"data": [
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
"data/map_data.xml",
|
"data/map_data.xml",
|
||||||
"views/account_bank_statement_import_sheet_mapping.xml",
|
"views/account_statement_import_sheet_mapping.xml",
|
||||||
"views/account_bank_statement_import.xml",
|
"views/account_statement_import.xml",
|
||||||
"views/account_journal_views.xml",
|
"views/account_journal_views.xml",
|
||||||
"wizards/account_bank_statement_import_sheet_mapping_wizard.xml",
|
"wizards/account_statement_import_sheet_mapping_wizard.xml",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,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).
|
||||||
-->
|
-->
|
||||||
<odoo noupdate="1">
|
<odoo noupdate="1">
|
||||||
<record
|
<record id="sample_statement_map" model="account.statement.import.sheet.mapping">
|
||||||
id="sample_statement_map"
|
|
||||||
model="account.bank.statement.import.sheet.mapping"
|
|
||||||
>
|
|
||||||
<field name="name">Sample Statement</field>
|
<field name="name">Sample Statement</field>
|
||||||
<field name="float_thousands_sep">comma</field>
|
<field name="float_thousands_sep">comma</field>
|
||||||
<field name="float_decimal_sep">dot</field>
|
<field name="float_decimal_sep">dot</field>
|
||||||
6
account_statement_import_txt_xlsx/models/__init__.py
Normal file
6
account_statement_import_txt_xlsx/models/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import account_statement_import_sheet_mapping
|
||||||
|
from . import account_statement_import_sheet_parser
|
||||||
|
from . import account_statement_import
|
||||||
|
from . import account_journal
|
||||||
@@ -9,7 +9,7 @@ class AccountJournal(models.Model):
|
|||||||
_inherit = "account.journal"
|
_inherit = "account.journal"
|
||||||
|
|
||||||
default_sheet_mapping_id = fields.Many2one(
|
default_sheet_mapping_id = fields.Many2one(
|
||||||
comodel_name="account.bank.statement.import.sheet.mapping",
|
comodel_name="account.statement.import.sheet.mapping",
|
||||||
)
|
)
|
||||||
|
|
||||||
def _get_bank_statements_available_import_formats(self):
|
def _get_bank_statements_available_import_formats(self):
|
||||||
@@ -8,8 +8,8 @@ from odoo import fields, models
|
|||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AccountBankStatementImport(models.TransientModel):
|
class AccountStatementImport(models.TransientModel):
|
||||||
_inherit = "account.bank.statement.import"
|
_inherit = "account.statement.import"
|
||||||
|
|
||||||
def _get_default_mapping_id(self):
|
def _get_default_mapping_id(self):
|
||||||
return (
|
return (
|
||||||
@@ -20,17 +20,17 @@ class AccountBankStatementImport(models.TransientModel):
|
|||||||
|
|
||||||
sheet_mapping_id = fields.Many2one(
|
sheet_mapping_id = fields.Many2one(
|
||||||
string="Sheet mapping",
|
string="Sheet mapping",
|
||||||
comodel_name="account.bank.statement.import.sheet.mapping",
|
comodel_name="account.statement.import.sheet.mapping",
|
||||||
default=_get_default_mapping_id,
|
default=_get_default_mapping_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _parse_file(self, data_file):
|
def _parse_file(self, data_file):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
try:
|
try:
|
||||||
Parser = self.env["account.bank.statement.import.sheet.parser"]
|
Parser = self.env["account.statement.import.sheet.parser"]
|
||||||
return Parser.parse(data_file, self.sheet_mapping_id)
|
return Parser.parse(data_file, self.sheet_mapping_id)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
if self.env.context.get("account_bank_statement_import_txt_xlsx_test"):
|
if self.env.context.get("account_statement_import_txt_xlsx_test"):
|
||||||
raise
|
raise
|
||||||
_logger.warning("Sheet parser error", exc_info=True)
|
_logger.warning("Sheet parser error", exc_info=True)
|
||||||
return super()._parse_file(data_file)
|
return super()._parse_file(data_file)
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class AccountBankStatementImportSheetMapping(models.Model):
|
class AccountStatementImportSheetMapping(models.Model):
|
||||||
_name = "account.bank.statement.import.sheet.mapping"
|
_name = "account.statement.import.sheet.mapping"
|
||||||
_description = "Account Bank Statement Import Sheet Mapping"
|
_description = "Bank Statement Import Sheet Mapping"
|
||||||
|
|
||||||
name = fields.Char(
|
name = fields.Char(
|
||||||
required=True,
|
required=True,
|
||||||
@@ -21,9 +21,9 @@ except (ImportError, IOError) as err: # pragma: no cover
|
|||||||
_logger.error(err)
|
_logger.error(err)
|
||||||
|
|
||||||
|
|
||||||
class AccountBankStatementImportSheetParser(models.TransientModel):
|
class AccountStatementImportSheetParser(models.TransientModel):
|
||||||
_name = "account.bank.statement.import.sheet.parser"
|
_name = "account.statement.import.sheet.parser"
|
||||||
_description = "Account Bank Statement Import Sheet Parser"
|
_description = "Bank Statement Import Sheet Parser"
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def parse_header(self, data_file, encoding, csv_options):
|
def parse_header(self, data_file, encoding, csv_options):
|
||||||
@@ -263,12 +263,6 @@ class AccountBankStatementImportSheetParser(models.TransientModel):
|
|||||||
if debit_credit == mapping.debit_value:
|
if debit_credit == mapping.debit_value:
|
||||||
amount = -amount
|
amount = -amount
|
||||||
|
|
||||||
if not original_currency:
|
|
||||||
original_currency = currency
|
|
||||||
original_amount = amount
|
|
||||||
elif original_currency == currency:
|
|
||||||
original_amount = amount
|
|
||||||
|
|
||||||
if original_amount:
|
if original_amount:
|
||||||
original_amount = self._parse_decimal(
|
original_amount = self._parse_decimal(
|
||||||
original_amount, mapping
|
original_amount, mapping
|
||||||
@@ -303,7 +297,7 @@ class AccountBankStatementImportSheetParser(models.TransientModel):
|
|||||||
return lines
|
return lines
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _convert_line_to_transactions(self, line):
|
def _convert_line_to_transactions(self, line): # noqa: C901
|
||||||
"""Hook for extension"""
|
"""Hook for extension"""
|
||||||
timestamp = line["timestamp"]
|
timestamp = line["timestamp"]
|
||||||
amount = line["amount"]
|
amount = line["amount"]
|
||||||
@@ -322,18 +316,30 @@ class AccountBankStatementImportSheetParser(models.TransientModel):
|
|||||||
"date": timestamp,
|
"date": timestamp,
|
||||||
"amount": str(amount),
|
"amount": str(amount),
|
||||||
}
|
}
|
||||||
if currency != original_currency:
|
|
||||||
|
if original_currency == currency:
|
||||||
|
original_currency = None
|
||||||
|
if not amount:
|
||||||
|
amount = original_amount
|
||||||
|
original_amount = "0.0"
|
||||||
|
|
||||||
|
if original_currency:
|
||||||
original_currency = self.env["res.currency"].search(
|
original_currency = self.env["res.currency"].search(
|
||||||
[("name", "=", original_currency)],
|
[("name", "=", original_currency)],
|
||||||
limit=1,
|
limit=1,
|
||||||
)
|
)
|
||||||
if original_currency:
|
if original_currency:
|
||||||
transaction.update(
|
transaction["foreign_currency_id"] = original_currency.id
|
||||||
{
|
if original_amount:
|
||||||
"amount_currency": str(original_amount),
|
transaction["amount_currency"] = str(original_amount)
|
||||||
"currency_id": original_currency.id,
|
|
||||||
}
|
if currency:
|
||||||
)
|
currency = self.env["res.currency"].search(
|
||||||
|
[("name", "=", currency)],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
|
if currency:
|
||||||
|
transaction["currency_id"] = currency.id
|
||||||
|
|
||||||
if transaction_id:
|
if transaction_id:
|
||||||
transaction["unique_import_id"] = "{}-{}".format(
|
transaction["unique_import_id"] = "{}-{}".format(
|
||||||
@@ -341,7 +347,7 @@ class AccountBankStatementImportSheetParser(models.TransientModel):
|
|||||||
int(timestamp.timestamp()),
|
int(timestamp.timestamp()),
|
||||||
)
|
)
|
||||||
|
|
||||||
transaction["name"] = description or _("N/A")
|
transaction["payment_ref"] = description or _("N/A")
|
||||||
if reference:
|
if reference:
|
||||||
transaction["ref"] = reference
|
transaction["ref"] = reference
|
||||||
|
|
||||||
@@ -357,7 +363,7 @@ class AccountBankStatementImportSheetParser(models.TransientModel):
|
|||||||
elif note:
|
elif note:
|
||||||
note = note.strip()
|
note = note.strip()
|
||||||
if note:
|
if note:
|
||||||
transaction["note"] = note
|
transaction["narration"] = note
|
||||||
|
|
||||||
if partner_name:
|
if partner_name:
|
||||||
transaction["partner_name"] = partner_name
|
transaction["partner_name"] = partner_name
|
||||||
2
account_statement_import_txt_xlsx/readme/DESCRIPTION.rst
Normal file
2
account_statement_import_txt_xlsx/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
This module allows you to import any TXT/CSV or XLSX file in Odoo as bank
|
||||||
|
statements.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||||
|
access_account_statement_import_sheet_mapping_manager,account.statement.import.sheet.mapping:account.group_account_manager,model_account_statement_import_sheet_mapping,account.group_account_manager,1,1,1,1
|
||||||
|
access_account_statement_import_sheet_mapping_user,account.statement.import.sheet.mapping:account.group_account_user,model_account_statement_import_sheet_mapping,account.group_account_user,1,0,0,0
|
||||||
|
access_account_statement_import_sheet_parser,account.statement.import.sheet.parser:account.group_account_user,model_account_statement_import_sheet_parser,account.group_account_user,1,1,1,1
|
||||||
|
access_account_statement_import_sheet_mapping_wizard,Full access on account.statement.import.sheet.mapping.wizard,model_account_statement_import_sheet_mapping_wizard,account.group_account_user,1,1,1,1
|
||||||
|
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||||
<title>Account Bank Statement Import TXT/CSV/XLSX</title>
|
<title>Bank Statement TXT/CSV/XLSX Import</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -360,15 +360,15 @@ ul.auto-toc {
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="document" id="account-bank-statement-import-txt-csv-xlsx">
|
<div class="document" id="bank-statement-txt-csv-xlsx-import">
|
||||||
<h1 class="title">Account Bank Statement Import TXT/CSV/XLSX</h1>
|
<h1 class="title">Bank Statement TXT/CSV/XLSX Import</h1>
|
||||||
|
|
||||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_txt_xlsx"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-statement-import-13-0/bank-statement-import-13-0-account_bank_statement_import_txt_xlsx"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/174/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_txt_xlsx"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-statement-import-14-0/bank-statement-import-14-0-account_statement_import_txt_xlsx"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/174/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This module allows you to import the any TXT/CSV or XLSX file in Odoo as bank
|
<p>This module allows you to import any TXT/CSV or XLSX file in Odoo as bank
|
||||||
statements.</p>
|
statements.</p>
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
@@ -421,7 +421,7 @@ statements.</p>
|
|||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
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
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_bank_statement_import_txt_xlsx%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_txt_xlsx%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
@@ -463,7 +463,7 @@ mission is to support the collaborative development of Odoo features and
|
|||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||||
<p><a class="reference external" href="https://github.com/alexey-pelykh"><img alt="alexey-pelykh" src="https://github.com/alexey-pelykh.png?size=40px" /></a></p>
|
<p><a class="reference external" href="https://github.com/alexey-pelykh"><img alt="alexey-pelykh" src="https://github.com/alexey-pelykh.png?size=40px" /></a></p>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_txt_xlsx">OCA/bank-statement-import</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_txt_xlsx">OCA/bank-statement-import</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
# 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 . import test_account_bank_statement_import_txt_xlsx
|
from . import test_account_statement_import_txt_xlsx
|
||||||
3
account_statement_import_txt_xlsx/tests/fixtures/sample_statement_en.csv
vendored
Normal file
3
account_statement_import_txt_xlsx/tests/fixtures/sample_statement_en.csv
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
"Date","Label","Currency","Amount","Amount Currency","Partner Name","Bank Account"
|
||||||
|
"12/15/2018","Your best supplier on 12/15/2018","USD","-33.50","0.0","John Doe","123456789"
|
||||||
|
"12/15/2018","Your payment on 12/15/2018","EUR","1,525.00","1,000.00","Azure Interior",""
|
||||||
|
BIN
account_statement_import_txt_xlsx/tests/fixtures/sample_statement_en.xlsx
vendored
Normal file
BIN
account_statement_import_txt_xlsx/tests/fixtures/sample_statement_en.xlsx
vendored
Normal file
Binary file not shown.
@@ -18,16 +18,16 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
self.currency_eur = self.env.ref("base.EUR")
|
self.currency_eur = self.env.ref("base.EUR")
|
||||||
self.currency_usd = self.env.ref("base.USD")
|
self.currency_usd = self.env.ref("base.USD")
|
||||||
self.sample_statement_map = self.env.ref(
|
self.sample_statement_map = self.env.ref(
|
||||||
"account_bank_statement_import_txt_xlsx.sample_statement_map"
|
"account_statement_import_txt_xlsx.sample_statement_map"
|
||||||
)
|
)
|
||||||
self.AccountJournal = self.env["account.journal"]
|
self.AccountJournal = self.env["account.journal"]
|
||||||
self.AccountBankStatement = self.env["account.bank.statement"]
|
self.AccountBankStatement = self.env["account.bank.statement"]
|
||||||
self.AccountBankStatementImport = self.env["account.bank.statement.import"]
|
self.AccountStatementImport = self.env["account.statement.import"]
|
||||||
self.AccountBankStatementImportSheetMapping = self.env[
|
self.AccountStatementImportSheetMapping = self.env[
|
||||||
"account.bank.statement.import.sheet.mapping"
|
"account.statement.import.sheet.mapping"
|
||||||
]
|
]
|
||||||
self.AccountBankStatementImportSheetMappingWizard = self.env[
|
self.AccountStatementImportSheetMappingWizard = self.env[
|
||||||
"account.bank.statement.import.sheet.mapping.wizard"
|
"account.statement.import.sheet.mapping.wizard"
|
||||||
]
|
]
|
||||||
|
|
||||||
def _data_file(self, filename, encoding=None):
|
def _data_file(self, filename, encoding=None):
|
||||||
@@ -48,19 +48,16 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/sample_statement_en.csv", "utf-8")
|
data = self._data_file("fixtures/sample_statement_en.csv", "utf-8")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/sample_statement_en.csv",
|
||||||
(0, 0, {"name": "fixtures/sample_statement_en.csv", "datas": data})
|
"statement_file": data,
|
||||||
],
|
|
||||||
"sheet_mapping_id": self.sample_statement_map.id,
|
"sheet_mapping_id": self.sample_statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 1)
|
self.assertEqual(len(statement), 1)
|
||||||
self.assertEqual(len(statement.line_ids), 2)
|
self.assertEqual(len(statement.line_ids), 2)
|
||||||
@@ -75,20 +72,17 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/empty_statement_en.csv", "utf-8")
|
data = self._data_file("fixtures/empty_statement_en.csv", "utf-8")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/empty_statement_en.csv",
|
||||||
(0, 0, {"name": "fixtures/empty_statement_en.csv", "datas": data})
|
"statement_file": data,
|
||||||
],
|
|
||||||
"sheet_mapping_id": self.sample_statement_map.id,
|
"sheet_mapping_id": self.sample_statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
with self.assertRaises(UserError):
|
with self.assertRaises(UserError):
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 0)
|
self.assertEqual(len(statement), 0)
|
||||||
|
|
||||||
@@ -102,19 +96,16 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/sample_statement_en.xlsx")
|
data = self._data_file("fixtures/sample_statement_en.xlsx")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/sample_statement_en.xlsx",
|
||||||
(0, 0, {"name": "fixtures/sample_statement_en.xlsx", "datas": data})
|
"statement_file": data,
|
||||||
],
|
|
||||||
"sheet_mapping_id": self.sample_statement_map.id,
|
"sheet_mapping_id": self.sample_statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 1)
|
self.assertEqual(len(statement), 1)
|
||||||
self.assertEqual(len(statement.line_ids), 2)
|
self.assertEqual(len(statement.line_ids), 2)
|
||||||
@@ -129,25 +120,22 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/empty_statement_en.xlsx")
|
data = self._data_file("fixtures/empty_statement_en.xlsx")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/empty_statement_en.xlsx",
|
||||||
(0, 0, {"name": "fixtures/empty_statement_en.xlsx", "datas": data})
|
"statement_file": data,
|
||||||
],
|
|
||||||
"sheet_mapping_id": self.sample_statement_map.id,
|
"sheet_mapping_id": self.sample_statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
with self.assertRaises(UserError):
|
with self.assertRaises(UserError):
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 0)
|
self.assertEqual(len(statement), 0)
|
||||||
|
|
||||||
def test_mapping_import_wizard_xlsx(self):
|
def test_mapping_import_wizard_xlsx(self):
|
||||||
with common.Form(self.AccountBankStatementImportSheetMappingWizard) as form:
|
with common.Form(self.AccountStatementImportSheetMappingWizard) as form:
|
||||||
attachment = self.env["ir.attachment"].create(
|
attachment = self.env["ir.attachment"].create(
|
||||||
{
|
{
|
||||||
"name": "fixtures/empty_statement_en.xlsx",
|
"name": "fixtures/empty_statement_en.xlsx",
|
||||||
@@ -158,7 +146,7 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
self.assertEqual(len(form.header), 90)
|
self.assertEqual(len(form.header), 90)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(
|
len(
|
||||||
self.AccountBankStatementImportSheetMappingWizard.with_context(
|
self.AccountStatementImportSheetMappingWizard.with_context(
|
||||||
header=form.header,
|
header=form.header,
|
||||||
).statement_columns()
|
).statement_columns()
|
||||||
),
|
),
|
||||||
@@ -170,7 +158,7 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
wizard.import_mapping()
|
wizard.import_mapping()
|
||||||
|
|
||||||
def test_mapping_import_wizard_csv(self):
|
def test_mapping_import_wizard_csv(self):
|
||||||
with common.Form(self.AccountBankStatementImportSheetMappingWizard) as form:
|
with common.Form(self.AccountStatementImportSheetMappingWizard) as form:
|
||||||
attachment = self.env["ir.attachment"].create(
|
attachment = self.env["ir.attachment"].create(
|
||||||
{
|
{
|
||||||
"name": "fixtures/empty_statement_en.csv",
|
"name": "fixtures/empty_statement_en.csv",
|
||||||
@@ -181,7 +169,7 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
self.assertEqual(len(form.header), 90)
|
self.assertEqual(len(form.header), 90)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(
|
len(
|
||||||
self.AccountBankStatementImportSheetMappingWizard.with_context(
|
self.AccountStatementImportSheetMappingWizard.with_context(
|
||||||
header=form.header,
|
header=form.header,
|
||||||
).statement_columns()
|
).statement_columns()
|
||||||
),
|
),
|
||||||
@@ -202,25 +190,24 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/original_currency.csv", "utf-8")
|
data = self._data_file("fixtures/original_currency.csv", "utf-8")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/original_currency.csv",
|
||||||
(0, 0, {"name": "fixtures/original_currency.csv", "datas": data})
|
"statement_file": data,
|
||||||
],
|
|
||||||
"sheet_mapping_id": self.sample_statement_map.id,
|
"sheet_mapping_id": self.sample_statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 1)
|
self.assertEqual(len(statement), 1)
|
||||||
self.assertEqual(len(statement.line_ids), 1)
|
self.assertEqual(len(statement.line_ids), 1)
|
||||||
|
|
||||||
line = statement.line_ids
|
line = statement.line_ids
|
||||||
self.assertEqual(line.currency_id, self.currency_eur)
|
self.assertEqual(line.currency_id, self.currency_usd)
|
||||||
|
self.assertEqual(line.amount, 1525.0)
|
||||||
|
self.assertEqual(line.foreign_currency_id, self.currency_eur)
|
||||||
self.assertEqual(line.amount_currency, 1000.0)
|
self.assertEqual(line.amount_currency, 1000.0)
|
||||||
|
|
||||||
def test_original_currency_empty(self):
|
def test_original_currency_empty(self):
|
||||||
@@ -233,29 +220,22 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/original_currency_empty.csv", "utf-8")
|
data = self._data_file("fixtures/original_currency_empty.csv", "utf-8")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/original_currency_empty.csv",
|
||||||
(
|
"statement_file": data,
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{"name": "fixtures/original_currency_empty.csv", "datas": data},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
"sheet_mapping_id": self.sample_statement_map.id,
|
"sheet_mapping_id": self.sample_statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 1)
|
self.assertEqual(len(statement), 1)
|
||||||
self.assertEqual(len(statement.line_ids), 1)
|
self.assertEqual(len(statement.line_ids), 1)
|
||||||
|
|
||||||
line = statement.line_ids
|
line = statement.line_ids
|
||||||
self.assertFalse(line.currency_id)
|
self.assertFalse(line.foreign_currency_id)
|
||||||
self.assertEqual(line.amount_currency, 0.0)
|
self.assertEqual(line.amount_currency, 0.0)
|
||||||
|
|
||||||
def test_multi_currency(self):
|
def test_multi_currency(self):
|
||||||
@@ -275,25 +255,22 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/multi_currency.csv", "utf-8")
|
data = self._data_file("fixtures/multi_currency.csv", "utf-8")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/multi_currency.csv",
|
||||||
(0, 0, {"name": "fixtures/multi_currency.csv", "datas": data})
|
"statement_file": data,
|
||||||
],
|
|
||||||
"sheet_mapping_id": statement_map.id,
|
"sheet_mapping_id": statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 1)
|
self.assertEqual(len(statement), 1)
|
||||||
self.assertEqual(len(statement.line_ids), 1)
|
self.assertEqual(len(statement.line_ids), 1)
|
||||||
|
|
||||||
line = statement.line_ids
|
line = statement.line_ids
|
||||||
self.assertFalse(line.currency_id)
|
self.assertFalse(line.foreign_currency_id)
|
||||||
self.assertEqual(line.amount, -33.5)
|
self.assertEqual(line.amount, -33.5)
|
||||||
|
|
||||||
def test_balance(self):
|
def test_balance(self):
|
||||||
@@ -313,19 +290,16 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/balance.csv", "utf-8")
|
data = self._data_file("fixtures/balance.csv", "utf-8")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/balance.csv",
|
||||||
(0, 0, {"name": "fixtures/balance.csv", "datas": data})
|
"statement_file": data,
|
||||||
],
|
|
||||||
"sheet_mapping_id": statement_map.id,
|
"sheet_mapping_id": statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 1)
|
self.assertEqual(len(statement), 1)
|
||||||
self.assertEqual(len(statement.line_ids), 2)
|
self.assertEqual(len(statement.line_ids), 2)
|
||||||
@@ -353,19 +327,16 @@ class TestAccountBankStatementImportTxtXlsx(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = self._data_file("fixtures/debit_credit.csv", "utf-8")
|
data = self._data_file("fixtures/debit_credit.csv", "utf-8")
|
||||||
wizard = self.AccountBankStatementImport.with_context(
|
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||||
journal_id=journal.id
|
|
||||||
).create(
|
|
||||||
{
|
{
|
||||||
"attachment_ids": [
|
"statement_filename": "fixtures/debit_credit.csv",
|
||||||
(0, 0, {"name": "fixtures/debit_credit.csv", "datas": data})
|
"statement_file": data,
|
||||||
],
|
|
||||||
"sheet_mapping_id": statement_map.id,
|
"sheet_mapping_id": statement_map.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
account_bank_statement_import_txt_xlsx_test=True
|
account_statement_import_txt_xlsx_test=True
|
||||||
).import_file()
|
).import_file_button()
|
||||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||||
self.assertEqual(len(statement), 1)
|
self.assertEqual(len(statement), 1)
|
||||||
self.assertEqual(len(statement.line_ids), 2)
|
self.assertEqual(len(statement.line_ids), 2)
|
||||||
@@ -5,12 +5,12 @@
|
|||||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="account_bank_statement_import_view" model="ir.ui.view">
|
<record id="account_statement_import_form" model="ir.ui.view">
|
||||||
<field name="name">account.bank.statement.import</field>
|
<field name="name">account.statement.import</field>
|
||||||
<field name="model">account.bank.statement.import</field>
|
<field name="model">account.statement.import</field>
|
||||||
<field
|
<field
|
||||||
name="inherit_id"
|
name="inherit_id"
|
||||||
ref="account_bank_statement_import.account_bank_statement_import_view"
|
ref="account_statement_import.account_statement_import_form"
|
||||||
/>
|
/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//ul[@id='statement_format']" position="inside">
|
<xpath expr="//ul[@id='statement_format']" position="inside">
|
||||||
@@ -5,18 +5,18 @@
|
|||||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="account_bank_statement_import_sheet_mapping_form" model="ir.ui.view">
|
<record id="account_statement_import_sheet_mapping_form" model="ir.ui.view">
|
||||||
<field name="name">account.bank.statement.import.sheet.mapping.form</field>
|
<field name="name">account.statement.import.sheet.mapping.form</field>
|
||||||
<field name="model">account.bank.statement.import.sheet.mapping</field>
|
<field name="model">account.statement.import.sheet.mapping</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="account_bank_statement_import_sheet_mapping_tree" model="ir.ui.view">
|
<record id="account_statement_import_sheet_mapping_tree" model="ir.ui.view">
|
||||||
<field name="name">account.bank.statement.import.sheet.mapping.tree</field>
|
<field name="name">account.statement.import.sheet.mapping.tree</field>
|
||||||
<field name="model">account.bank.statement.import.sheet.mapping</field>
|
<field name="model">account.statement.import.sheet.mapping</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<form>
|
||||||
<sheet>
|
<sheet>
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
model="ir.actions.act_window"
|
model="ir.actions.act_window"
|
||||||
>
|
>
|
||||||
<field name="name">Statement Sheet Mappings</field>
|
<field name="name">Statement Sheet Mappings</field>
|
||||||
<field name="res_model">account.bank.statement.import.sheet.mapping</field>
|
<field name="res_model">account.statement.import.sheet.mapping</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
<menuitem
|
<menuitem
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
# 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 . import account_bank_statement_import_sheet_mapping_wizard
|
from . import account_statement_import_sheet_mapping_wizard
|
||||||
@@ -9,16 +9,16 @@ from os import path
|
|||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class AccountBankStatementImportSheetMappingWizard(models.TransientModel):
|
class AccountStatementImportSheetMappingWizard(models.TransientModel):
|
||||||
_name = "account.bank.statement.import.sheet.mapping.wizard"
|
_name = "account.statement.import.sheet.mapping.wizard"
|
||||||
_description = "Account Bank Statement Import Sheet Mapping Wizard"
|
_description = "Bank Statement Import Sheet Mapping Wizard"
|
||||||
_inherit = ["multi.step.wizard.mixin"]
|
_inherit = ["multi.step.wizard.mixin"]
|
||||||
|
|
||||||
attachment_ids = fields.Many2many(
|
attachment_ids = fields.Many2many(
|
||||||
comodel_name="ir.attachment",
|
comodel_name="ir.attachment",
|
||||||
string="Files",
|
string="Files",
|
||||||
required=True,
|
required=True,
|
||||||
relation="account_bank_statement_import_sheet_mapping_wiz_attachment_rel",
|
relation="account_statement_import_sheet_mapping_wiz_attachment_rel",
|
||||||
)
|
)
|
||||||
header = fields.Char()
|
header = fields.Char()
|
||||||
file_encoding = fields.Selection(
|
file_encoding = fields.Selection(
|
||||||
@@ -111,7 +111,7 @@ class AccountBankStatementImportSheetMappingWizard(models.TransientModel):
|
|||||||
@api.model
|
@api.model
|
||||||
def _selection_file_encoding(self):
|
def _selection_file_encoding(self):
|
||||||
return (
|
return (
|
||||||
self.env["account.bank.statement.import.sheet.mapping"]
|
self.env["account.statement.import.sheet.mapping"]
|
||||||
._fields["file_encoding"]
|
._fields["file_encoding"]
|
||||||
.selection
|
.selection
|
||||||
)
|
)
|
||||||
@@ -119,15 +119,15 @@ class AccountBankStatementImportSheetMappingWizard(models.TransientModel):
|
|||||||
@api.model
|
@api.model
|
||||||
def _selection_delimiter(self):
|
def _selection_delimiter(self):
|
||||||
return (
|
return (
|
||||||
self.env["account.bank.statement.import.sheet.mapping"]
|
self.env["account.statement.import.sheet.mapping"]
|
||||||
._fields["delimiter"]
|
._fields["delimiter"]
|
||||||
.selection
|
.selection
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.onchange("attachment_ids")
|
@api.onchange("attachment_ids")
|
||||||
def _onchange_attachment_ids(self):
|
def _onchange_attachment_ids(self):
|
||||||
Parser = self.env["account.bank.statement.import.sheet.parser"]
|
Parser = self.env["account.statement.import.sheet.parser"]
|
||||||
Mapping = self.env["account.bank.statement.import.sheet.mapping"]
|
Mapping = self.env["account.statement.import.sheet.mapping"]
|
||||||
if not self.attachment_ids:
|
if not self.attachment_ids:
|
||||||
return
|
return
|
||||||
csv_options = {}
|
csv_options = {}
|
||||||
@@ -184,13 +184,13 @@ class AccountBankStatementImportSheetMappingWizard(models.TransientModel):
|
|||||||
|
|
||||||
def import_mapping(self):
|
def import_mapping(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
mapping = self.env["account.bank.statement.import.sheet.mapping"].create(
|
mapping = self.env["account.statement.import.sheet.mapping"].create(
|
||||||
self._get_mapping_values()
|
self._get_mapping_values()
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
"name": _("Imported Mapping"),
|
"name": _("Imported Mapping"),
|
||||||
"res_model": "account.bank.statement.import.sheet.mapping",
|
"res_model": "account.statement.import.sheet.mapping",
|
||||||
"res_id": mapping.id,
|
"res_id": mapping.id,
|
||||||
"view_mode": "form",
|
"view_mode": "form",
|
||||||
"view_id": False,
|
"view_id": False,
|
||||||
@@ -5,14 +5,9 @@
|
|||||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record
|
<record id="account_statement_import_sheet_mapping_wizard_form" model="ir.ui.view">
|
||||||
id="account_bank_statement_import_sheet_mapping_wizard_form"
|
<field name="name">account.statement.import.sheet.mapping.wizard.form</field>
|
||||||
model="ir.ui.view"
|
<field name="model">account.statement.import.sheet.mapping.wizard</field>
|
||||||
>
|
|
||||||
<field
|
|
||||||
name="name"
|
|
||||||
>account.bank.statement.import.sheet.mapping.wizard.form</field>
|
|
||||||
<field name="model">account.bank.statement.import.sheet.mapping.wizard</field>
|
|
||||||
<field name="mode">primary</field>
|
<field name="mode">primary</field>
|
||||||
<field name="inherit_id" ref="multi_step_wizard.multi_step_wizard_form" />
|
<field name="inherit_id" ref="multi_step_wizard.multi_step_wizard_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
@@ -151,12 +146,17 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<act_window
|
<record
|
||||||
id="action_account_bank_statement_import_sheet_mapping_wizard"
|
id="action_account_statement_import_sheet_mapping_wizard"
|
||||||
name="Import Mapping"
|
model="ir.actions.act_window"
|
||||||
res_model="account.bank.statement.import.sheet.mapping.wizard"
|
>
|
||||||
binding_model="account.bank.statement.import.sheet.mapping"
|
<field name="name">Import Mapping</field>
|
||||||
view_mode="form"
|
<field name="res_model">account.statement.import.sheet.mapping.wizard</field>
|
||||||
target="new"
|
<field
|
||||||
/>
|
name="binding_model_id"
|
||||||
|
ref="model_account_statement_import_sheet_mapping"
|
||||||
|
/>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../../account_bank_statement_import_txt_xlsx
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../../account_statement_import_txt_xlsx
|
||||||
Reference in New Issue
Block a user