From 578abd8278d61bfe3237ae403d74744e744095b9 Mon Sep 17 00:00:00 2001 From: Sergio Zanchetta Date: Thu, 9 Sep 2021 21:14:02 +0200 Subject: [PATCH] [IMP] account_bank_statement_import_txt_xlsx: black, isort, prettier --- ...unt_bank_statement_import_sheet_mapping.py | 35 +++++++++---- ...ount_bank_statement_import_sheet_parser.py | 7 ++- ...k_statement_import_sheet_mapping_wizard.py | 49 ++++++++++++++----- requirements.txt | 1 + .../account_bank_statement_import_txt_xlsx | 1 + .../setup.py | 6 +++ 6 files changed, 75 insertions(+), 24 deletions(-) create mode 120000 setup/account_bank_statement_import_txt_xlsx/odoo/addons/account_bank_statement_import_txt_xlsx create mode 100644 setup/account_bank_statement_import_txt_xlsx/setup.py diff --git a/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_mapping.py b/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_mapping.py index 4e90b0df..bec696c3 100644 --- a/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_mapping.py +++ b/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_mapping.py @@ -9,7 +9,9 @@ class AccountBankStatementImportSheetMapping(models.Model): _name = "account.bank.statement.import.sheet.mapping" _description = "Account Bank Statement Import Sheet Mapping" - name = fields.Char(required=True,) + name = fields.Char( + required=True, + ) float_thousands_sep = fields.Selection( string="Thousands Separator", selection=[("dot", "dot (.)"), ("comma", "comma (,)"), ("none", "none")], @@ -68,7 +70,8 @@ class AccountBankStatementImportSheetMapping(models.Model): help="Amount of transaction in journal's currency", ) balance_column = fields.Char( - string="Balance column", help="Balance after transaction in journal's currency", + string="Balance column", + help="Balance after transaction in journal's currency", ) original_currency_column = fields.Char( string="Original currency column", @@ -103,14 +106,28 @@ class AccountBankStatementImportSheetMapping(models.Model): help="Value of debit/credit column that indicates if it's a credit", default="C", ) - transaction_id_column = fields.Char(string="Unique transaction ID column",) - description_column = fields.Char(string="Description column",) - notes_column = fields.Char(string="Notes column",) - reference_column = fields.Char(string="Reference column",) - partner_name_column = fields.Char(string="Partner Name column",) - bank_name_column = fields.Char(string="Bank Name column", help="Partner's bank",) + transaction_id_column = fields.Char( + string="Unique transaction ID column", + ) + description_column = fields.Char( + string="Description column", + ) + notes_column = fields.Char( + string="Notes column", + ) + reference_column = fields.Char( + string="Reference column", + ) + partner_name_column = fields.Char( + string="Partner Name column", + ) + bank_name_column = fields.Char( + string="Bank Name column", + help="Partner's bank", + ) bank_account_column = fields.Char( - string="Bank Account column", help="Partner's bank account", + string="Bank Account column", + help="Partner's bank account", ) @api.onchange("float_thousands_sep") diff --git a/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_parser.py b/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_parser.py index 58766adc..c92c9168 100644 --- a/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_parser.py +++ b/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_parser.py @@ -14,6 +14,7 @@ _logger = logging.getLogger(__name__) try: from csv import reader + import xlrd from xlrd.xldate import xldate_as_datetime except (ImportError, IOError) as err: # pragma: no cover @@ -323,7 +324,8 @@ class AccountBankStatementImportSheetParser(models.TransientModel): } if currency != original_currency: original_currency = self.env["res.currency"].search( - [("name", "=", original_currency)], limit=1, + [("name", "=", original_currency)], + limit=1, ) if original_currency: transaction.update( @@ -335,7 +337,8 @@ class AccountBankStatementImportSheetParser(models.TransientModel): if transaction_id: transaction["unique_import_id"] = "{}-{}".format( - transaction_id, int(timestamp.timestamp()), + transaction_id, + int(timestamp.timestamp()), ) transaction["name"] = description or _("N/A") diff --git a/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_sheet_mapping_wizard.py b/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_sheet_mapping_wizard.py index 430deefa..e7021017 100644 --- a/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_sheet_mapping_wizard.py +++ b/account_bank_statement_import_txt_xlsx/wizards/account_bank_statement_import_sheet_mapping_wizard.py @@ -22,13 +22,20 @@ class AccountBankStatementImportSheetMappingWizard(models.TransientModel): ) header = fields.Char() file_encoding = fields.Selection( - string="Encoding", selection=lambda self: self._selection_file_encoding(), + string="Encoding", + selection=lambda self: self._selection_file_encoding(), ) delimiter = fields.Selection( - string="Delimiter", selection=lambda self: self._selection_delimiter(), + string="Delimiter", + selection=lambda self: self._selection_delimiter(), + ) + quotechar = fields.Char( + string="Text qualifier", + size=1, + ) + timestamp_column = fields.Char( + string="Timestamp column", ) - quotechar = fields.Char(string="Text qualifier", size=1,) - timestamp_column = fields.Char(string="Timestamp column",) currency_column = fields.Char( string="Currency column", help=( @@ -37,10 +44,12 @@ class AccountBankStatementImportSheetMappingWizard(models.TransientModel): ), ) amount_column = fields.Char( - string="Amount column", help="Amount of transaction in journal's currency", + string="Amount column", + help="Amount of transaction in journal's currency", ) balance_column = fields.Char( - string="Balance column", help="Balance after transaction in journal's currency", + string="Balance column", + help="Balance after transaction in journal's currency", ) original_currency_column = fields.Char( string="Original currency column", @@ -75,14 +84,28 @@ class AccountBankStatementImportSheetMappingWizard(models.TransientModel): help="Value of debit/credit column that indicates if it's a credit", default="C", ) - transaction_id_column = fields.Char(string="Unique transaction ID column",) - description_column = fields.Char(string="Description column",) - notes_column = fields.Char(string="Notes column",) - reference_column = fields.Char(string="Reference column",) - partner_name_column = fields.Char(string="Partner Name column",) - bank_name_column = fields.Char(string="Bank Name column", help="Partner's bank",) + transaction_id_column = fields.Char( + string="Unique transaction ID column", + ) + description_column = fields.Char( + string="Description column", + ) + notes_column = fields.Char( + string="Notes column", + ) + reference_column = fields.Char( + string="Reference column", + ) + partner_name_column = fields.Char( + string="Partner Name column", + ) + bank_name_column = fields.Char( + string="Bank Name column", + help="Partner's bank", + ) bank_account_column = fields.Char( - string="Bank Account column", help="Partner's bank account", + string="Bank Account column", + help="Partner's bank account", ) @api.model diff --git a/requirements.txt b/requirements.txt index ddf34beb..6fff9265 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ # generated from manifests external_dependencies ofxparse +xlrd diff --git a/setup/account_bank_statement_import_txt_xlsx/odoo/addons/account_bank_statement_import_txt_xlsx b/setup/account_bank_statement_import_txt_xlsx/odoo/addons/account_bank_statement_import_txt_xlsx new file mode 120000 index 00000000..38905400 --- /dev/null +++ b/setup/account_bank_statement_import_txt_xlsx/odoo/addons/account_bank_statement_import_txt_xlsx @@ -0,0 +1 @@ +../../../../account_bank_statement_import_txt_xlsx \ No newline at end of file diff --git a/setup/account_bank_statement_import_txt_xlsx/setup.py b/setup/account_bank_statement_import_txt_xlsx/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_bank_statement_import_txt_xlsx/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)