Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zaoral committed Feb 8, 2023
1 parent f4828ea commit 314f417
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 98 deletions.
7 changes: 5 additions & 2 deletions account_statement_import_txt_xlsx/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
)

Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -32,92 +32,27 @@
<group name="final" attrs="{'invisible': [('state', '!=', 'final')]}">
<group colspan="2">
<field name="header" invisible="1" />
<field name="header_ids" />
<field
name="timestamp_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
attrs="{'required': [('state', '=', 'final')]}"
/>
<field
name="currency_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field name="currency_column" />
<field
name="amount_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
attrs="{'required': [('state', '=', 'final')]}"
/>
<field
name="balance_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="original_currency_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="original_amount_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="debit_credit_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="transaction_id_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="description_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="notes_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="reference_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="partner_name_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="bank_name_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field
name="bank_account_column"
widget="dynamic_dropdown"
values="statement_columns"
context="{'header': header}"
/>
<field name="balance_column" />
<field name="original_currency_column" />
<field name="original_amount_column" />
<field name="debit_credit_column" />
<field name="transaction_id_column" />
<field name="description_column" />
<field name="notes_column" />
<field name="reference_column" />
<field name="partner_name_column" />
<field name="bank_name_column" />
<field name="bank_account_column" />
</group>
<group
string="Debit/Credit column"
Expand Down

0 comments on commit 314f417

Please sign in to comment.