diff --git a/account_statement_import_txt_xlsx/__manifest__.py b/account_statement_import_txt_xlsx/__manifest__.py index faaccd247d..6e38654867 100644 --- a/account_statement_import_txt_xlsx/__manifest__.py +++ b/account_statement_import_txt_xlsx/__manifest__.py @@ -14,8 +14,11 @@ "installable": True, "depends": [ "account_statement_import", - "multi_step_wizard", - "web_widget_dropdown_dynamic", + # TODO KZ esto ya esta migrado a version 16, asi que lo pudiesemos usar + # ver realmente que suma + # "multi_step_wizard", + # TODO KZ no esta migrado, lo comentamos e intetamos no depender de el. + # "web_widget_dropdown_dynamic", ], "external_dependencies": {"python": ["xlrd"]}, "data": [ diff --git a/account_statement_import_txt_xlsx/tests/test_account_statement_import_txt_xlsx.py b/account_statement_import_txt_xlsx/tests/test_account_statement_import_txt_xlsx.py index 0ffecd9303..eac7e112a7 100644 --- a/account_statement_import_txt_xlsx/tests/test_account_statement_import_txt_xlsx.py +++ b/account_statement_import_txt_xlsx/tests/test_account_statement_import_txt_xlsx.py @@ -160,6 +160,7 @@ def test_mapping_import_wizard_xlsx(self): wizard.import_mapping() def test_mapping_import_wizard_csv(self): + # TODO remove statement_columns logic does not exist anymore with common.Form(self.AccountStatementImportSheetMappingWizard) as form: attachment = self.env["ir.attachment"].create( { diff --git a/account_statement_import_txt_xlsx/wizards/account_statement_import_sheet_mapping_wizard.py b/account_statement_import_txt_xlsx/wizards/account_statement_import_sheet_mapping_wizard.py index 47f4eeab27..ac52bff279 100644 --- a/account_statement_import_txt_xlsx/wizards/account_statement_import_sheet_mapping_wizard.py +++ b/account_statement_import_txt_xlsx/wizards/account_statement_import_sheet_mapping_wizard.py @@ -32,34 +32,42 @@ class AccountStatementImportSheetMappingWizard(models.TransientModel): string="Text qualifier", size=1, ) - timestamp_column = fields.Char() - currency_column = fields.Char( + timestamp_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line" + ) + currency_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", help=( "In case statement is multi-currency, column to get currency of " "transaction from" ), ) - amount_column = fields.Char( + amount_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", help="Amount of transaction in journal's currency", ) - balance_column = fields.Char( + balance_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", help="Balance after transaction in journal's currency", ) - original_currency_column = fields.Char( + original_currency_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", help=( "In case statement provides original currency for transactions " "with automatic currency conversion, column to get original " "currency of transaction from" ), ) - original_amount_column = fields.Char( + original_amount_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", help=( "In case statement provides original currency for transactions " "with automatic currency conversion, column to get original " "transaction amount in original transaction currency from" ), ) - debit_credit_column = fields.Char( + debit_credit_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", string="Debit/credit column", help=( "Some statement formats use absolute amount value and indicate sign" @@ -74,17 +82,28 @@ class AccountStatementImportSheetMappingWizard(models.TransientModel): help="Value of debit/credit column that indicates if it's a credit", default="C", ) - transaction_id_column = fields.Char( + transaction_id_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", string="Unique transaction ID column", ) - description_column = fields.Char() - notes_column = fields.Char() - reference_column = fields.Char() - partner_name_column = fields.Char() - bank_name_column = fields.Char( + description_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", + ) + notes_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", + ) + reference_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", + ) + partner_name_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", + ) + bank_name_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", help="Partner's bank", ) - bank_account_column = fields.Char( + bank_account_column = fields.Many2one( + "account.statement.import.sheet.mapping.wizard.line", help="Partner's bank account", ) @@ -124,13 +143,16 @@ def _onchange_attachment_ids(self): ) header = list(set(header)) self.header = json.dumps(header) + import pdb + + pdb.set_trace() + self.header_ids = [(0, 0, {"name": item}) for item in self.header] - @api.model def statement_columns(self): - header = self.env.context.get("header") - if not header: + self.ensure_one() + if self.header: return [] - return [(x, x) for x in json.loads(header)] + return [(x, x) for x in json.loads(self.header)] def _get_mapping_values(self): """Hook for extension""" @@ -176,3 +198,17 @@ def import_mapping(self): "view_id": False, "target": "current", } + + header_ids = fields.One2many( + "account.statement.import.sheet.mapping.wizard.line", + inverse_name="wiz_id", + string="Columns", + ) + + +class AccountStatementImportSheetMappingWizardLine(models.TransientModel): + _name = "account.statement.import.sheet.mapping.wizard.line" + _description = "Bank Statement Import Sheet Mapping Wizard Line" + + wiz_id = fields.Many2one("iaccount.statement.import.sheet.mapping.wizard") + name = fields.Char() diff --git a/account_statement_import_txt_xlsx/wizards/account_statement_import_sheet_mapping_wizard.xml b/account_statement_import_txt_xlsx/wizards/account_statement_import_sheet_mapping_wizard.xml index 51097816f5..5dd83f29ec 100644 --- a/account_statement_import_txt_xlsx/wizards/account_statement_import_sheet_mapping_wizard.xml +++ b/account_statement_import_txt_xlsx/wizards/account_statement_import_sheet_mapping_wizard.xml @@ -32,92 +32,27 @@ + - + - - - - - - - - - - - + + + + + + + + + + +