mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[12.0][add] account_bank_statement_import_txt_xslx
This commit is contained in:
committed by
Sergio Zanchetta
parent
f61d288db8
commit
4f9baf7108
103
account_bank_statement_import_txt_xlsx/README.rst
Normal file
103
account_bank_statement_import_txt_xlsx/README.rst
Normal file
@@ -0,0 +1,103 @@
|
||||
======================================
|
||||
Account Bank Statement Import TXT XLSX
|
||||
======================================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/bank-statement-import/tree/12.0/account_bank_statement_import_txt_xlsx
|
||||
:alt: OCA/bank-statement-import
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/bank-statement-import-12-0/bank-statement-import-12-0-account_bank_statement_import_txt_xlsx
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/174/12.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module allows you to import the any TXT/CSV or XLSX file in Odoo as bank
|
||||
statements.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
* Create or go to a bank journal where you want to import the txt statement.
|
||||
* Edit that journal and set a Txt map in **Statement Import Map** section in **Advanced
|
||||
Settings** tab.
|
||||
|
||||
* Now you can import Text based statements in that journal.
|
||||
|
||||
Note: if existent Txt Map does not fit to your file to import, you can
|
||||
create another map in **Invoicing > Configuration > Accounting >
|
||||
Statement Import Map**.
|
||||
|
||||
You can import headers from any Txt file in **Action > Create Map
|
||||
Lines** and set every line with which field of statement have to match.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use this module, you need to:
|
||||
|
||||
#. Go to your bank online and download your Bank Statement in TXT/CSV or XLSX format.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
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.
|
||||
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:%2012.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.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Eficent
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
* Sebastien BEAU <sebastien.beau@akretion.com>
|
||||
* Tecnativa (https://www.tecnativa.com)
|
||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
* Victor M.M. Torres <victor.martin@tecnativa.com>
|
||||
* Eficent (https://www.eficent.com)
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/12.0/account_bank_statement_import_txt_xlsx>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
2
account_bank_statement_import_txt_xlsx/__init__.py
Normal file
2
account_bank_statement_import_txt_xlsx/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import models
|
||||
from . import wizards
|
||||
28
account_bank_statement_import_txt_xlsx/__manifest__.py
Normal file
28
account_bank_statement_import_txt_xlsx/__manifest__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Copyright 2014-2017 Akretion (http://www.akretion.com).
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Account Bank Statement Import TXT XLSX",
|
||||
'summary': 'Import TXT/CSV or XLSX files as Bank Statements in Odoo',
|
||||
"version": "12.0.1.0.1",
|
||||
"category": "Accounting",
|
||||
"website": "https://github.com/OCA/bank-statement-import",
|
||||
"author": " Eficent, Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"account_bank_statement_import",
|
||||
],
|
||||
"external_dependencies": {
|
||||
"python": ["xlrd"],
|
||||
},
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"data/txt_map_data.xml",
|
||||
"wizards/create_map_lines_from_file_views.xml",
|
||||
"wizards/account_bank_statement_import_view.xml",
|
||||
"views/account_journal_views.xml",
|
||||
"views/txt_map_views.xml",
|
||||
]
|
||||
}
|
||||
53
account_bank_statement_import_txt_xlsx/data/txt_map_data.xml
Normal file
53
account_bank_statement_import_txt_xlsx/data/txt_map_data.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="txt_map" model="account.bank.statement.import.map">
|
||||
<field name="name">Sample Statement</field>
|
||||
<field name="float_thousands_sep">comma</field>
|
||||
<field name="float_decimal_sep">dot</field>
|
||||
</record>
|
||||
|
||||
<record id="txt_map_line_date" model="account.bank.statement.import.map.line">
|
||||
<field name="name">Date</field>
|
||||
<field name="sequence">0</field>
|
||||
<field name="map_parent_id" ref="txt_map"/>
|
||||
<field name="field_to_assign">date</field>
|
||||
<field name="date_format">%m/%d/%Y</field>
|
||||
</record>
|
||||
<record id="txt_map_line_name" model="account.bank.statement.import.map.line">
|
||||
<field name="name">Label</field>
|
||||
<field name="sequence">1</field>
|
||||
<field name="map_parent_id" ref="txt_map"/>
|
||||
<field name="field_to_assign">name</field>
|
||||
</record>
|
||||
<record id="txt_map_line_currency" model="account.bank.statement.import.map.line">
|
||||
<field name="name">Currency</field>
|
||||
<field name="sequence">2</field>
|
||||
<field name="map_parent_id" ref="txt_map"/>
|
||||
<field name="field_to_assign">currency</field>
|
||||
</record>
|
||||
<record id="txt_map_line_amount" model="account.bank.statement.import.map.line">
|
||||
<field name="name">Amount</field>
|
||||
<field name="sequence">3</field>
|
||||
<field name="map_parent_id" ref="txt_map"/>
|
||||
<field name="field_to_assign">amount</field>
|
||||
</record>
|
||||
<record id="txt_map_line_amount_currency" model="account.bank.statement.import.map.line">
|
||||
<field name="name">Amount Currency</field>
|
||||
<field name="sequence">4</field>
|
||||
<field name="map_parent_id" ref="txt_map"/>
|
||||
<field name="field_to_assign">amount_currency</field>
|
||||
</record>
|
||||
<record id="txt_map_line_partner_name" model="account.bank.statement.import.map.line">
|
||||
<field name="name">Partner Name</field>
|
||||
<field name="sequence">5</field>
|
||||
<field name="map_parent_id" ref="txt_map"/>
|
||||
<field name="field_to_assign">partner_name</field>
|
||||
</record>
|
||||
<record id="txt_map_line_account_number" model="account.bank.statement.import.map.line">
|
||||
<field name="name">Bank Account</field>
|
||||
<field name="sequence">6</field>
|
||||
<field name="map_parent_id" ref="txt_map"/>
|
||||
<field name="field_to_assign">account_number</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -0,0 +1,420 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_bank_statement_import_txt_xlsx
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 12.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: code:addons/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_txt.py:236
|
||||
#, python-format
|
||||
msgid "%s Import %s > %s"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model,name:account_bank_statement_import_txt_xlsx.model_account_bank_statement_import_map
|
||||
msgid "Account Bank Statement Import Txt Map"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model,name:account_bank_statement_import_txt_xlsx.model_account_bank_statement_import_map_line
|
||||
msgid "Account Bank Statement Import Txt Map Line"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.create_txt_map_lines_view
|
||||
msgid "All the txt map lines will be created automatically."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
msgid "Amount in foreign currency"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
msgid "Amount in the journal currency"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: code:addons/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_txt.py:160
|
||||
#, python-format
|
||||
msgid "An error was found translating a date field from the file: %s"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
msgid "Bank Account Number"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create__data_file
|
||||
msgid "Bank Statement File"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.create_txt_map_lines_view
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.create_txt_map_lines_view
|
||||
msgid "Choose a file to import..."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.create_txt_map_lines_view
|
||||
msgid "Create Lines"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.actions.act_window,name:account_bank_statement_import_txt_xlsx.action_create_txt_map_lines
|
||||
msgid "Create Statement Map Lines"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__create_uid
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__create_uid
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create__create_uid
|
||||
msgid "Created by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__create_date
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__create_date
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create__create_date
|
||||
msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
msgid "Currency"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
msgid "Date"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__date_format
|
||||
msgid "Date Format"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: code:addons/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_txt.py:111
|
||||
#, python-format
|
||||
msgid "Date format of map file and Txt date does not match."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__float_decimal_sep
|
||||
msgid "Decimals separator"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__display_name
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__display_name
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.create_txt_map_lines_view
|
||||
msgid "Download a bank statement from your bank and import it here."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__file_encoding
|
||||
msgid "Encoding"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__sequence
|
||||
msgid "Field number"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create__filename
|
||||
msgid "Filename"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__name
|
||||
msgid "Header Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: code:addons/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_txt.py:74
|
||||
#: code:addons/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_txt.py:91
|
||||
#, python-format
|
||||
msgid "Headers of file to import and Txt map lines does not match."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__id
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__id
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model,name:account_bank_statement_import_txt_xlsx.model_account_bank_statement_import
|
||||
msgid "Import Bank Statement"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.create_txt_map_lines_view
|
||||
msgid "Import Txt Map Lines"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model,name:account_bank_statement_import_txt_xlsx.model_account_journal
|
||||
msgid "Journal"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
msgid "Label"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map____last_update
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line____last_update
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__write_uid
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__write_uid
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create__write_uid
|
||||
msgid "Last Updated by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__write_date
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__write_date
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_wizard_txt_map_create__write_date
|
||||
msgid "Last Updated on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__map_parent_id
|
||||
msgid "Map Parent"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__map_line_ids
|
||||
msgid "Map lines"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.statement_import_map_tax_form
|
||||
msgid "Mapping Lines"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__name
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
msgid "Notes"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,field_to_assign:0
|
||||
msgid "Reference"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.create_txt_map_lines_view
|
||||
msgid "Select a TXT/CSV or XLSX bank statement file to create all the map lines from headers file."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__delimiter
|
||||
msgid "Separated by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,delimiter:0
|
||||
msgid "Space"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map_line__field_to_assign
|
||||
msgid "Statement Field to Assign"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.ui.menu,name:account_bank_statement_import_txt_xlsx.menu_statement_import_txt_mapping
|
||||
msgid "Statement Import Map"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.actions.act_window,name:account_bank_statement_import_txt_xlsx.action_statement_import_txt_mappging
|
||||
msgid "Statement Import Mapping"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_journal__statement_import_txt_map_id
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.view_account_journal_form_n43
|
||||
msgid "Statement Import Txt Map"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__quotechar
|
||||
msgid "String delimiter"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,delimiter:0
|
||||
msgid "Tab"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import_map__float_thousands_sep
|
||||
msgid "Thousands separator"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.statement_import_map_tax_form
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.statement_import_map_tax_tree
|
||||
msgid "Txt Map"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model.fields,field_description:account_bank_statement_import_txt_xlsx.field_account_bank_statement_import__txt_map_id
|
||||
msgid "Txt map"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.statement_import_map_tax_line_form
|
||||
msgid "Txt mapping line"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.statement_import_map_tax_line_tree
|
||||
msgid "Txt mapping lines"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_txt_xlsx.account_bank_statement_import_view
|
||||
msgid "Txt/XLSX file with Template:"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "UTF-16"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "UTF-8"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: code:addons/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_txt.py:120
|
||||
#, python-format
|
||||
msgid "Value '%s' for the field '%s' on line %d, cannot be converted to float"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "Windows-1252"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: model:ir.model,name:account_bank_statement_import_txt_xlsx.model_wizard_txt_map_create
|
||||
msgid "Wizard Txt Map Create"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: code:addons/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_txt.py:190
|
||||
#, python-format
|
||||
msgid "You must run this wizard from the journal"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "big5"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,delimiter:0
|
||||
#: selection:account.bank.statement.import.map,float_decimal_sep:0
|
||||
#: selection:account.bank.statement.import.map,float_thousands_sep:0
|
||||
msgid "comma (,)"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,delimiter:0
|
||||
#: selection:account.bank.statement.import.map,float_decimal_sep:0
|
||||
#: selection:account.bank.statement.import.map,float_thousands_sep:0
|
||||
msgid "dot (.)"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "gb18030"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,date_format:0
|
||||
msgid "i.e. 12/15/2019"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map.line,date_format:0
|
||||
msgid "i.e. 15/12/2019"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "koir9_r"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "latin1"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "latin2"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,delimiter:0
|
||||
#: selection:account.bank.statement.import.map,float_decimal_sep:0
|
||||
#: selection:account.bank.statement.import.map,float_thousands_sep:0
|
||||
msgid "none"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,delimiter:0
|
||||
msgid "semicolon (;)"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "shift_jis"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_txt_xlsx
|
||||
#: selection:account.bank.statement.import.map,file_encoding:0
|
||||
msgid "windows-1251"
|
||||
msgstr ""
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
from . import account_bank_statement_import_txt_map
|
||||
from . import account_journal
|
||||
@@ -0,0 +1,136 @@
|
||||
# Copyright 2019 Tecnativa - Vicent Cubells
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
class AccountBankStatementImportTxtMap(models.Model):
|
||||
_name = 'account.bank.statement.import.map'
|
||||
_description = 'Account Bank Statement Import Txt Map'
|
||||
|
||||
name = fields.Char(
|
||||
required=True,
|
||||
)
|
||||
map_line_ids = fields.One2many(
|
||||
comodel_name='account.bank.statement.import.map.line',
|
||||
inverse_name='map_parent_id',
|
||||
string="Map lines",
|
||||
required=True,
|
||||
copy=True,
|
||||
)
|
||||
float_thousands_sep = fields.Selection(
|
||||
[('dot', 'dot (.)'),
|
||||
('comma', 'comma (,)'),
|
||||
('none', 'none'),
|
||||
],
|
||||
string='Thousands separator',
|
||||
# forward compatibility: this was the value assumed
|
||||
# before the field was added.
|
||||
default='dot',
|
||||
required=True
|
||||
)
|
||||
float_decimal_sep = fields.Selection(
|
||||
[('dot', 'dot (.)'),
|
||||
('comma', 'comma (,)'),
|
||||
('none', 'none'),
|
||||
],
|
||||
string='Decimals separator',
|
||||
# forward compatibility: this was the value assumed
|
||||
# before the field was added.
|
||||
default='comma',
|
||||
required=True
|
||||
)
|
||||
file_encoding = fields.Selection(
|
||||
string='Encoding',
|
||||
selection=[
|
||||
('utf-8', 'UTF-8'),
|
||||
('utf-16 ', 'UTF-16'),
|
||||
('windows-1252', 'Windows-1252'),
|
||||
('latin1', 'latin1'),
|
||||
('latin2', 'latin2'),
|
||||
('big5', 'big5'),
|
||||
('gb18030', 'gb18030'),
|
||||
('shift_jis', 'shift_jis'),
|
||||
('windows-1251', 'windows-1251'),
|
||||
('koir8_r', 'koir9_r'),
|
||||
],
|
||||
default='utf-8',
|
||||
)
|
||||
delimiter = fields.Selection(
|
||||
string='Separated by',
|
||||
selection=[
|
||||
('.', 'dot (.)'),
|
||||
(',', 'comma (,)'),
|
||||
(';', 'semicolon (;)'),
|
||||
('', 'none'),
|
||||
('\t', 'Tab'),
|
||||
(' ', 'Space'),
|
||||
],
|
||||
default=',',
|
||||
)
|
||||
quotechar = fields.Char(string='String delimiter', size=1,
|
||||
default='"')
|
||||
|
||||
@api.onchange('float_thousands_sep')
|
||||
def onchange_thousands_separator(self):
|
||||
if 'dot' == self.float_thousands_sep == self.float_decimal_sep:
|
||||
self.float_decimal_sep = 'comma'
|
||||
elif 'comma' == self.float_thousands_sep == self.float_decimal_sep:
|
||||
self.float_decimal_sep = 'dot'
|
||||
|
||||
@api.onchange('float_decimal_sep')
|
||||
def onchange_decimal_separator(self):
|
||||
if 'dot' == self.float_thousands_sep == self.float_decimal_sep:
|
||||
self.float_thousands_sep = 'comma'
|
||||
elif 'comma' == self.float_thousands_sep == self.float_decimal_sep:
|
||||
self.float_thousands_sep = 'dot'
|
||||
|
||||
def _get_separators(self):
|
||||
separators = {'dot': '.',
|
||||
'comma': ',',
|
||||
'none': '',
|
||||
}
|
||||
return (separators[self.float_thousands_sep],
|
||||
separators[self.float_decimal_sep])
|
||||
|
||||
|
||||
class AccountBankStatementImportTxtMapLine(models.Model):
|
||||
_name = 'account.bank.statement.import.map.line'
|
||||
_description = 'Account Bank Statement Import Txt Map Line'
|
||||
_order = "sequence asc, id asc"
|
||||
|
||||
sequence = fields.Integer(
|
||||
string="Field number",
|
||||
required=True,
|
||||
)
|
||||
name = fields.Char(
|
||||
string="Header Name",
|
||||
required=True,
|
||||
)
|
||||
map_parent_id = fields.Many2one(
|
||||
comodel_name='account.bank.statement.import.map',
|
||||
required=True,
|
||||
ondelete='cascade',
|
||||
)
|
||||
field_to_assign = fields.Selection(
|
||||
selection=[
|
||||
('date', 'Date'),
|
||||
('name', 'Label'),
|
||||
('currency', 'Currency'),
|
||||
('amount', 'Amount in the journal currency'),
|
||||
('amount_currency', 'Amount in foreign currency'),
|
||||
('ref', 'Reference'),
|
||||
('note', 'Notes'),
|
||||
('partner_name', 'Name'),
|
||||
('account_number', 'Bank Account Number'),
|
||||
],
|
||||
string="Statement Field to Assign",
|
||||
)
|
||||
date_format = fields.Selection(
|
||||
selection=[
|
||||
('%d/%m/%Y', 'i.e. 15/12/2019'),
|
||||
('%m/%d/%Y', 'i.e. 12/15/2019'),
|
||||
],
|
||||
string="Date Format",
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 2019 Tecnativa - Vicent Cubells
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
_inherit = "account.journal"
|
||||
|
||||
statement_import_txt_map_id = fields.Many2one(
|
||||
comodel_name='account.bank.statement.import.map',
|
||||
string='Statement Import Txt Map',
|
||||
)
|
||||
|
||||
def _get_bank_statements_available_import_formats(self):
|
||||
res = super()._get_bank_statements_available_import_formats()
|
||||
res.append('Txt')
|
||||
return res
|
||||
12
account_bank_statement_import_txt_xlsx/readme/CONFIGURE.rst
Normal file
12
account_bank_statement_import_txt_xlsx/readme/CONFIGURE.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
* Create or go to a bank journal where you want to import the txt statement.
|
||||
* Edit that journal and set a Txt map in **Statement Import Map** section in **Advanced
|
||||
Settings** tab.
|
||||
|
||||
* Now you can import Text based statements in that journal.
|
||||
|
||||
Note: if existent Txt Map does not fit to your file to import, you can
|
||||
create another map in **Invoicing > Configuration > Accounting >
|
||||
Statement Import Map**.
|
||||
|
||||
You can import headers from any Txt file in **Action > Create Map
|
||||
Lines** and set every line with which field of statement have to match.
|
||||
@@ -0,0 +1,7 @@
|
||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
* Sebastien BEAU <sebastien.beau@akretion.com>
|
||||
* Tecnativa (https://www.tecnativa.com)
|
||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
* Victor M.M. Torres <victor.martin@tecnativa.com>
|
||||
* Eficent (https://www.eficent.com)
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
@@ -0,0 +1,2 @@
|
||||
This module allows you to import the any TXT/CSV or XLSX file in Odoo as bank
|
||||
statements.
|
||||
3
account_bank_statement_import_txt_xlsx/readme/USAGE.rst
Normal file
3
account_bank_statement_import_txt_xlsx/readme/USAGE.rst
Normal file
@@ -0,0 +1,3 @@
|
||||
To use this module, you need to:
|
||||
|
||||
#. Go to your bank online and download your Bank Statement in TXT/CSV or XLSX format.
|
||||
@@ -0,0 +1,3 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
access_account_bank_statement_import_map,map manager,model_account_bank_statement_import_map,account.group_account_manager,1,1,1,1
|
||||
access_account_bank_statement_import_map_line,map line manager,model_account_bank_statement_import_map_line,account.group_account_manager,1,1,1,1
|
||||
|
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,449 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<title>Account Bank Statement Import TXT XLSX</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="account-bank-statement-import-txt-xlsx">
|
||||
<h1 class="title">Account Bank Statement Import TXT XLSX</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! 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/12.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-12-0/bank-statement-import-12-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/12.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
|
||||
statements.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
|
||||
<ul class="simple">
|
||||
<li>Create or go to a bank journal where you want to import the txt statement.</li>
|
||||
<li>Edit that journal and set a Txt map in <strong>Statement Import Map</strong> section in <strong>Advanced
|
||||
Settings</strong> tab.</li>
|
||||
<li>Now you can import Text based statements in that journal.</li>
|
||||
</ul>
|
||||
<p>Note: if existent Txt Map does not fit to your file to import, you can
|
||||
create another map in <strong>Invoicing > Configuration > Accounting >
|
||||
Statement Import Map</strong>.</p>
|
||||
<p>You can import headers from any Txt file in <strong>Action > Create Map
|
||||
Lines</strong> and set every line with which field of statement have to match.</p>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
|
||||
<p>To use this module, you need to:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Go to your bank online and download your Bank Statement in TXT/CSV or XLSX format.</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
|
||||
<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.
|
||||
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:%2012.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>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Eficent</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Alexis de Lattre <<a class="reference external" href="mailto:alexis.delattre@akretion.com">alexis.delattre@akretion.com</a>></li>
|
||||
<li>Sebastien BEAU <<a class="reference external" href="mailto:sebastien.beau@akretion.com">sebastien.beau@akretion.com</a>></li>
|
||||
<li>Tecnativa (<a class="reference external" href="https://www.tecnativa.com">https://www.tecnativa.com</a>)
|
||||
* Vicent Cubells <<a class="reference external" href="mailto:vicent.cubells@tecnativa.com">vicent.cubells@tecnativa.com</a>>
|
||||
* Victor M.M. Torres <<a class="reference external" href="mailto:victor.martin@tecnativa.com">victor.martin@tecnativa.com</a>></li>
|
||||
<li>Eficent (<a class="reference external" href="https://www.eficent.com">https://www.eficent.com</a>)
|
||||
* Jordi Ballester Alomar <<a class="reference external" href="mailto:jordi.ballester@eficent.com">jordi.ballester@eficent.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/12.0/account_bank_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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
1
account_bank_statement_import_txt_xlsx/tests/__init__.py
Normal file
1
account_bank_statement_import_txt_xlsx/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_txt_statement_import
|
||||
@@ -0,0 +1,3 @@
|
||||
"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.
@@ -0,0 +1,99 @@
|
||||
# Copyright 2019 Tecnativa - Vicent Cubells
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import os
|
||||
import base64
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestTxtFile(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTxtFile, self).setUp()
|
||||
|
||||
self.map = self.env['account.bank.statement.import.map'].create({
|
||||
'name': 'Txt Map Test',
|
||||
})
|
||||
usd = self.env.ref('base.USD')
|
||||
self.journal = self.env['account.journal'].create({
|
||||
'name': 'Txt Bank',
|
||||
'type': 'bank',
|
||||
'code': 'TXT',
|
||||
'currency_id': (
|
||||
usd.id if self.env.user.company_id.currency_id != usd
|
||||
else False
|
||||
),
|
||||
})
|
||||
|
||||
def _do_import_xlsx(self, file_name):
|
||||
file_name = os.path.join(os.path.dirname(__file__), file_name)
|
||||
with open(file_name, 'rb') as fin:
|
||||
data = fin.read()
|
||||
return data
|
||||
|
||||
def _do_import(self, file_name):
|
||||
file_name = os.path.join(os.path.dirname(__file__), file_name)
|
||||
return open(file_name).read()
|
||||
|
||||
def test_import_header(self):
|
||||
file = self._do_import('sample_statement_en.csv')
|
||||
file = base64.b64encode(file.encode("utf-8"))
|
||||
wizard = self.env['wizard.txt.map.create'].with_context({
|
||||
'journal_id': self.journal.id,
|
||||
'active_ids': [self.map.id],
|
||||
}).create({'data_file': file})
|
||||
wizard.create_map_lines()
|
||||
self.assertEqual(len(self.map.map_line_ids.ids), 7)
|
||||
|
||||
def test_import_txt_file(self):
|
||||
# Current statements before to run the wizard
|
||||
old_statements = self.env['account.bank.statement'].search([])
|
||||
# This journal is for Txt statements
|
||||
txt_map = self.env.ref(
|
||||
'account_bank_statement_import_txt_xlsx.txt_map'
|
||||
)
|
||||
self.journal.statement_import_txt_map_id = txt_map.id
|
||||
file = self._do_import('sample_statement_en.csv')
|
||||
file = base64.b64encode(file.encode("utf-8"))
|
||||
wizard = self.env['account.bank.statement.import'].with_context({
|
||||
'journal_id': self.journal.id,
|
||||
}).create({'data_file': file})
|
||||
wizard.import_file()
|
||||
staments_now = self.env['account.bank.statement'].search([])
|
||||
statement = staments_now - old_statements
|
||||
self.assertEqual(len(statement.line_ids), 2)
|
||||
self.assertEqual(len(statement.mapped('line_ids').filtered(
|
||||
lambda x: x.partner_id)), 1)
|
||||
self.assertAlmostEqual(
|
||||
sum(statement.mapped('line_ids.amount')), 1491.50
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
sum(statement.mapped('line_ids.amount_currency')), 1000.00
|
||||
)
|
||||
|
||||
def test_import_xlsx_file(self):
|
||||
# Current statements before to run the wizard
|
||||
old_statements = self.env['account.bank.statement'].search([])
|
||||
# This journal is for Txt statements
|
||||
txt_map = self.env.ref(
|
||||
'account_bank_statement_import_txt_xlsx.txt_map'
|
||||
)
|
||||
self.journal.statement_import_txt_map_id = txt_map.id
|
||||
file = self._do_import_xlsx('sample_statement_en.xlsx')
|
||||
file = base64.b64encode(file)
|
||||
wizard = self.env['account.bank.statement.import'].with_context({
|
||||
'journal_id': self.journal.id,
|
||||
}).create({'data_file': file})
|
||||
wizard.import_file()
|
||||
staments_now = self.env['account.bank.statement'].search([])
|
||||
statement = staments_now - old_statements
|
||||
self.assertEqual(len(statement.line_ids), 2)
|
||||
self.assertEqual(len(statement.mapped('line_ids').filtered(
|
||||
lambda x: x.partner_id)), 1)
|
||||
self.assertAlmostEqual(
|
||||
sum(statement.mapped('line_ids.amount')), 1491.50
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
sum(statement.mapped('line_ids.amount_currency')), 1000.00
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_account_journal_form_n43" model="ir.ui.view">
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='advanced_settings']/group" position="inside">
|
||||
<group string="Statement Import Txt Map" attrs="{'invisible': [('type','!=','bank')]}">
|
||||
<field name="statement_import_txt_map_id"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="statement_import_map_tax_tree" model="ir.ui.view">
|
||||
<field name="model">account.bank.statement.import.map</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Txt Map">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="statement_import_map_tax_form" model="ir.ui.view">
|
||||
<field name="model">account.bank.statement.import.map</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Txt Map">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="float_thousands_sep"/>
|
||||
<field name="float_decimal_sep"/>
|
||||
<field name="file_encoding"/>
|
||||
<field name="delimiter"/>
|
||||
<field name="quotechar"/>
|
||||
</group>
|
||||
<separator string="Mapping Lines"/>
|
||||
<field name="map_line_ids"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="statement_import_map_tax_line_tree" model="ir.ui.view">
|
||||
<field name="model">account.bank.statement.import.map.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Txt mapping lines" editable="bottom">
|
||||
<field name="sequence"/>
|
||||
<field name="name"/>
|
||||
<field name="field_to_assign"/>
|
||||
<field name="date_format" attrs="{'readonly':[('field_to_assign','!=','date')], 'required':[('field_to_assign','=','date')]}"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="statement_import_map_tax_line_form" model="ir.ui.view">
|
||||
<field name="model">account.bank.statement.import.map.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Txt mapping line">
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="sequence"/>
|
||||
<field name="field_to_assign"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_statement_import_txt_mappging">
|
||||
<field name="name">Statement Import Mapping</field>
|
||||
<field name="res_model">account.bank.statement.import.map</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_statement_import_txt_mapping"
|
||||
parent="account.account_account_menu"
|
||||
action="action_statement_import_txt_mappging"
|
||||
name="Statement Import Map"/>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,2 @@
|
||||
from . import create_map_lines_from_file
|
||||
from . import account_bank_statement_import_txt
|
||||
@@ -0,0 +1,288 @@
|
||||
# Copyright 2014-2017 Akretion (http://www.akretion.com).
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import xlrd
|
||||
import logging
|
||||
import datetime as dtm
|
||||
from datetime import datetime
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
import re
|
||||
from io import StringIO
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import csv
|
||||
except (ImportError, IOError) as err:
|
||||
_logger.debug(err)
|
||||
|
||||
|
||||
class AccountBankStatementImport(models.TransientModel):
|
||||
_inherit = 'account.bank.statement.import'
|
||||
|
||||
txt_map_id = fields.Many2one(
|
||||
comodel_name='account.bank.statement.import.map',
|
||||
string='Txt map',
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _get_txt_encoding(self):
|
||||
if self.txt_map_id.file_encoding:
|
||||
return self.txt_map_id.file_encoding
|
||||
return 'utf-8-sig'
|
||||
|
||||
@api.model
|
||||
def _get_txt_str_data(self, data_file):
|
||||
if not isinstance(data_file, str):
|
||||
data_file = data_file.decode(self._get_txt_encoding())
|
||||
return data_file.strip()
|
||||
|
||||
@api.model
|
||||
def _txt_convert_amount(self, amount_str):
|
||||
if not amount_str:
|
||||
return 0.0
|
||||
if self.txt_map_id:
|
||||
thousands, decimal = self.txt_map_id._get_separators()
|
||||
else:
|
||||
thousands, decimal = ',', '.'
|
||||
valstr = re.sub(r'[^\d%s%s.-]' % (thousands, decimal), '', amount_str)
|
||||
valstrdot = valstr.replace(thousands, '')
|
||||
valstrdot = valstrdot.replace(decimal, '.')
|
||||
return float(valstrdot)
|
||||
|
||||
@api.model
|
||||
def _check_xls(self, data_file):
|
||||
# Try if it is an Excel file
|
||||
headers = self.mapped('txt_map_id.map_line_ids.name')
|
||||
try:
|
||||
file_headers = []
|
||||
book = xlrd.open_workbook(file_contents=data_file)
|
||||
xl_sheet = book.sheet_by_index(0)
|
||||
row = xl_sheet.row(0) # 1st row
|
||||
for idx, cell_obj in enumerate(row):
|
||||
cell_type_str = xlrd.sheet.ctype_text.get(cell_obj.ctype, False)
|
||||
if cell_type_str:
|
||||
file_headers.append(cell_obj.value)
|
||||
else:
|
||||
return False
|
||||
if any(item not in file_headers for item in headers):
|
||||
raise UserError(
|
||||
_("Headers of file to import and Txt map lines does not "
|
||||
"match."))
|
||||
except xlrd.XLRDError as e:
|
||||
return False
|
||||
except Exception as e:
|
||||
return False
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def _check_txt(self, data_file):
|
||||
data_file = self._get_txt_str_data(data_file)
|
||||
if not self.txt_map_id:
|
||||
return False
|
||||
headers = self.mapped('txt_map_id.map_line_ids.name')
|
||||
file_headers = data_file.split('\n', 1)[0]
|
||||
if any(item not in file_headers for item in headers):
|
||||
raise UserError(
|
||||
_("Headers of file to import and Txt map lines does not "
|
||||
"match."))
|
||||
return True
|
||||
|
||||
def _get_currency_fields(self):
|
||||
return ['amount', 'amount_currency']
|
||||
|
||||
def _convert_txt_line_to_dict(self, idx, line):
|
||||
rline = dict()
|
||||
for item in range(len(line)):
|
||||
txt_map = self.mapped('txt_map_id.map_line_ids')[item]
|
||||
value = line[item]
|
||||
if not txt_map.field_to_assign:
|
||||
continue
|
||||
if txt_map.date_format:
|
||||
try:
|
||||
value = fields.Date.to_string(
|
||||
datetime.strptime(value, txt_map.date_format))
|
||||
except Exception:
|
||||
raise UserError(
|
||||
_("Date format of map file and Txt date does "
|
||||
"not match."))
|
||||
rline[txt_map.field_to_assign] = value
|
||||
for field in self._get_currency_fields():
|
||||
_logger.debug('Trying to convert %s to float' % rline[field])
|
||||
try:
|
||||
rline[field] = self._txt_convert_amount(rline[field])
|
||||
except Exception:
|
||||
raise UserError(
|
||||
_("Value '%s' for the field '%s' on line %d, "
|
||||
"cannot be converted to float")
|
||||
% (rline[field], field, idx))
|
||||
return rline
|
||||
|
||||
def _parse_txt_file(self, data_file):
|
||||
data_file = self._get_txt_str_data(data_file)
|
||||
f = StringIO(data_file)
|
||||
f.seek(0)
|
||||
raw_lines = []
|
||||
if not self.txt_map_id.quotechar:
|
||||
reader = csv.reader(f,
|
||||
delimiter=self.txt_map_id.delimiter or False)
|
||||
else:
|
||||
reader = csv.reader(f,
|
||||
quotechar=self.txt_map_id.quotechar,
|
||||
delimiter=self.txt_map_id.delimiter or False)
|
||||
next(reader) # Drop header
|
||||
for idx, line in enumerate(reader):
|
||||
_logger.debug("Line %d: %s" % (idx, line))
|
||||
raw_lines.append(self._convert_txt_line_to_dict(idx, line))
|
||||
return raw_lines
|
||||
|
||||
def _convert_xls_line_to_dict(self, row_idx, xl_sheet):
|
||||
rline = dict()
|
||||
for col_idx in range(0, xl_sheet.ncols): # Iterate through columns
|
||||
txt_map = self.mapped('txt_map_id.map_line_ids')[col_idx]
|
||||
cell_obj = xl_sheet.cell(row_idx, col_idx) # Get cell
|
||||
ctype = xl_sheet.cell(row_idx, col_idx).ctype
|
||||
value = cell_obj.value
|
||||
if not txt_map.field_to_assign:
|
||||
continue
|
||||
if ctype == xlrd.XL_CELL_DATE:
|
||||
ms_date_number = xl_sheet.cell(row_idx, col_idx).value
|
||||
try:
|
||||
year, month, day, hour, minute, \
|
||||
second = xlrd.xldate_as_tuple(
|
||||
ms_date_number, 0)
|
||||
except xlrd.XLDateError as e:
|
||||
raise UserError(
|
||||
_('An error was found translating a date '
|
||||
'field from the file: %s') % e)
|
||||
value = dtm.date(year, month, day)
|
||||
value = value.strftime('%Y-%m-%d')
|
||||
rline[txt_map.field_to_assign] = value
|
||||
|
||||
return rline
|
||||
|
||||
def _parse_xls_file(self, data_file):
|
||||
try:
|
||||
raw_lines = []
|
||||
book = xlrd.open_workbook(file_contents=data_file)
|
||||
xl_sheet = book.sheet_by_index(0)
|
||||
for row_idx in range(1, xl_sheet.nrows):
|
||||
_logger.debug("Line %d" % row_idx)
|
||||
raw_lines.append(self._convert_xls_line_to_dict(
|
||||
row_idx, xl_sheet))
|
||||
except xlrd.XLRDError:
|
||||
return False
|
||||
except Exception as e:
|
||||
return False
|
||||
return raw_lines
|
||||
|
||||
def _post_process_statement_line(self, raw_lines):
|
||||
""" Enter your additional logic here. """
|
||||
return raw_lines
|
||||
|
||||
def _get_journal(self):
|
||||
journal_id = self.env.context.get('journal_id')
|
||||
if not journal_id:
|
||||
raise UserError(_('You must run this wizard from the journal'))
|
||||
return self.env['account.journal'].browse(journal_id)
|
||||
|
||||
def _get_currency_id(self, fline):
|
||||
journal = self._get_journal()
|
||||
line_currency_name = fline.get('currency', False)
|
||||
currency = journal.currency_id or journal.company_id.currency_id
|
||||
if line_currency_name and line_currency_name != currency.name:
|
||||
currency = self.env['res.currency'].search(
|
||||
[('name', '=', fline['currency'])], limit=1)
|
||||
return currency.id
|
||||
return False
|
||||
|
||||
@api.model
|
||||
def _get_partner_id(self, fline):
|
||||
partner_name = fline.get('partner_name', False)
|
||||
if partner_name:
|
||||
partner = self.env['res.partner'].search([
|
||||
('name', '=ilike', partner_name)])
|
||||
if partner and len(partner) == 1:
|
||||
return partner.commercial_partner_id.id
|
||||
return None
|
||||
|
||||
def _prepare_txt_statement_line(self, fline):
|
||||
currency_id = self._get_currency_id(fline)
|
||||
return {
|
||||
'date': fline.get('date', False),
|
||||
'name': fline.get('name', ''),
|
||||
'ref': fline.get('ref', False),
|
||||
'note': fline.get('Notes', False),
|
||||
'amount': fline.get('amount', 0.0),
|
||||
'currency_id': self._get_currency_id(fline),
|
||||
'amount_currency': currency_id and fline.get(
|
||||
'amount_currency', 0.0) or 0.0,
|
||||
'partner_id': self._get_partner_id(fline),
|
||||
'account_number': fline.get('account_number', False),
|
||||
}
|
||||
|
||||
def _prepare_txt_statement(self, lines):
|
||||
balance_end_real = 0.0
|
||||
for line in lines:
|
||||
if 'amount' in line and line['amount']:
|
||||
balance_end_real += line['amount']
|
||||
|
||||
return {
|
||||
'name':
|
||||
_('%s Import %s > %s')
|
||||
% (self.txt_map_id.name,
|
||||
lines[0]['date'], lines[-1]['date']),
|
||||
'date': lines[-1]['date'],
|
||||
'balance_start': 0.0,
|
||||
'balance_end_real': balance_end_real,
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _parse_file(self, data_file):
|
||||
""" Import a file in Txt CSV format """
|
||||
is_txt = False
|
||||
is_xls = self._check_xls(data_file)
|
||||
if not is_xls:
|
||||
is_txt = self._check_txt(data_file)
|
||||
if not is_txt and not is_xls:
|
||||
return super(AccountBankStatementImport, self)._parse_file(
|
||||
data_file)
|
||||
if is_txt:
|
||||
raw_lines = self._parse_txt_file(data_file)
|
||||
else:
|
||||
raw_lines = self._parse_xls_file(data_file)
|
||||
final_lines = self._post_process_statement_line(raw_lines)
|
||||
vals_bank_statement = self._prepare_txt_statement(final_lines)
|
||||
transactions = []
|
||||
for fline in final_lines:
|
||||
vals_line = self._prepare_txt_statement_line(fline)
|
||||
_logger.debug("vals_line = %s" % vals_line)
|
||||
transactions.append(vals_line)
|
||||
vals_bank_statement['transactions'] = transactions
|
||||
return None, None, [vals_bank_statement]
|
||||
|
||||
@api.model
|
||||
def _complete_txt_statement_line(self, line):
|
||||
""" Enter additional logic here. """
|
||||
return None
|
||||
|
||||
@api.model
|
||||
def _complete_stmts_vals(self, stmts_vals, journal_id, account_number):
|
||||
stmts_vals = super(AccountBankStatementImport, self). \
|
||||
_complete_stmts_vals(stmts_vals, journal_id, account_number)
|
||||
for line in stmts_vals[0]['transactions']:
|
||||
vals = self._complete_txt_statement_line(line)
|
||||
if vals:
|
||||
line.update(vals)
|
||||
return stmts_vals
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(AccountBankStatementImport, self).default_get(fields)
|
||||
journal = self._get_journal()
|
||||
res['txt_map_id'] = journal.statement_import_txt_map_id.id
|
||||
return res
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="account_bank_statement_import_view" model="ir.ui.view">
|
||||
<field name="model">account.bank.statement.import</field>
|
||||
<field name="inherit_id" ref="account_bank_statement_import.account_bank_statement_import_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//ul[@id='statement_format']" position="inside">
|
||||
<li>Txt/XLSX file with Template: <field name="txt_map_id"/></li>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright 2019 Tecnativa - Vicent Cubells
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import csv
|
||||
import base64
|
||||
from odoo import api, fields, models
|
||||
from io import StringIO
|
||||
|
||||
|
||||
class WizardTxtMapCreate(models.TransientModel):
|
||||
_name = 'wizard.txt.map.create'
|
||||
_description = 'Wizard Txt Map Create'
|
||||
|
||||
data_file = fields.Binary(
|
||||
string='Bank Statement File',
|
||||
required=True,
|
||||
)
|
||||
filename = fields.Char()
|
||||
|
||||
@api.multi
|
||||
def create_map_lines(self):
|
||||
statement_obj = self.env['account.bank.statement.import.map']
|
||||
data_file = base64.b64decode(self.data_file)
|
||||
if not isinstance(data_file, str):
|
||||
data_file = data_file.decode('utf-8-sig').strip()
|
||||
file = StringIO(data_file)
|
||||
file.seek(0)
|
||||
reader = csv.reader(file)
|
||||
headers = []
|
||||
for row in reader:
|
||||
headers = row
|
||||
break
|
||||
lines = []
|
||||
for idx, title in enumerate(headers):
|
||||
lines.append((0, 0, {'sequence': idx, 'name': title}))
|
||||
if lines:
|
||||
for statement in statement_obj.browse(
|
||||
self.env.context.get('active_ids')):
|
||||
statement.map_line_ids = lines
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="create_txt_map_lines_view" model="ir.ui.view">
|
||||
<field name="name">Create Statement Map Lines</field>
|
||||
<field name="model">wizard.txt.map.create</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Import Txt Map Lines">
|
||||
<h2>Select a TXT/CSV or XLSX bank statement file to create all the map lines from headers file.</h2>
|
||||
<p>Download a bank statement from your bank and import it here.</p>
|
||||
<p>All the txt map lines will be created automatically.</p>
|
||||
<field name="data_file" filename="filename" placeholder="Choose a file to import..."/>
|
||||
<field name="filename" invisible="1"/>
|
||||
<footer>
|
||||
<button name="create_map_lines" string="Create Lines" type="object" class="btn-primary" />
|
||||
<button string="Cancel" class="btn-default" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<act_window name="Create Statement Map Lines"
|
||||
res_model="wizard.txt.map.create"
|
||||
src_model="account.bank.statement.import.map"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="action_create_txt_map_lines"/>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user