Skip to content

Commit

Permalink
account_import_helper: block if an account code has a double entry in…
Browse files Browse the repository at this point in the history
… the imported file
  • Loading branch information
alexis-via committed Nov 30, 2023
1 parent 5bfd166 commit b8473a6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion account_import_helper/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def generate_custom_chart(
}
)
custom_code_size = False
for (custom_code, src_custom_dict) in custom_chart:
for custom_code, src_custom_dict in custom_chart.items():
if fixed_size_code:
if custom_code_size:
if len(custom_code) != custom_code_size:
Expand Down
9 changes: 5 additions & 4 deletions account_import_helper/wizard/account_chart_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def run(self):
fileobj.seek(0)
wb = openpyxl.load_workbook(fileobj.name, read_only=True)
sh = wb.active
custom_chart = []
custom_chart = {}
i = 0
for row in sh.rows:
i += 1
Expand All @@ -67,9 +67,10 @@ def run(self):
if not code[:3].isdigit():
raise UserError(
_("Account '%s': the 3 first caracters are not digits") % code)
custom_chart.append(
(code, {"name": name, "note": note})
)
if code in custom_chart:
raise UserError(_(
"Double entry in the chart of account: account '%s'.") % code)
custom_chart[code] = {"name": name, "note": note}
fileobj.close()
pprint(custom_chart)
logger.info("Starting to generate CSV file")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
id="account_chart_generate_parent_menu"
parent="base.menu_custom"
name="Chart Generate"
sequence="-1"
/>

<menuitem
Expand Down

0 comments on commit b8473a6

Please sign in to comment.