Skip to content

[17.0][IMP] l10nl_bank script#440

Open
bosd wants to merge 2 commits intoOCA:17.0from
bosd:17.0-imp-l10nl_bank-script
Open

[17.0][IMP] l10nl_bank script#440
bosd wants to merge 2 commits intoOCA:17.0from
bosd:17.0-imp-l10nl_bank-script

Conversation

@bosd
Copy link
Copy Markdown
Contributor

@bosd bosd commented Aug 8, 2025

As mentioned in #424

Comment thread l10n_nl_bank/data/res_bank_data.xml Outdated
Comment thread l10n_nl_bank/readme/CONTRIBUTORS.md Outdated
@bosd bosd force-pushed the 17.0-imp-l10nl_bank-script branch from 35ce9b5 to ebc7d3b Compare August 8, 2025 17:17
Copy link
Copy Markdown
Member

@hbrunn hbrunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll need a migration script here that renames the xmlid of adyen and possibly other ones where the xmlid is changed. and then force-loads the file to update names like sns.

if you can easily instruct your statistical parrot to rewrite the script to use xlrd and requests instead of the pretty heavy pandas dependency, it would be nice because the former are already dependencies of odoo. but i won't block on this one

processed_banks.append((record_id, name, bic))

logging.info("✅ Data processed successfully.")
return sorted(processed_banks, key=lambda x: x[1])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return sorted(processed_banks, key=lambda x: x[1])
return sorted(processed_banks, key=lambda x: x[0])

to keep sorting by bic as the existing file does, should give a smaller diff and keep ordering stable for name changes

@bosd bosd force-pushed the 17.0-imp-l10nl_bank-script branch from ebc7d3b to 67fe689 Compare August 9, 2025 08:08
@bosd
Copy link
Copy Markdown
Contributor Author

bosd commented Aug 9, 2025

@hbrunn Thanks for the review.
🦜 Migration scripts added.
moved to openpyxl so from version 18 and on we are back in sync. (xlrd no longer supports xlsx files)

@bosd bosd requested a review from hbrunn August 9, 2025 08:16
Copy link
Copy Markdown
Member

@hbrunn hbrunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nearly every line of the migration scripts is wrong, but they won't run anyways because the version number isn't increased in the manifest

please only submit code you tested and verified to work as expected

Comment on lines +10 to +13
"""
This post-migration script re-enables the noupdate="1" flag on the bank
data file to prevent accidental data overwrites during future module upgrades.
"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comments in this file are very misleading, as they don't match what the code actually does

This post-migration script re-enables the noupdate="1" flag on the bank
data file to prevent accidental data overwrites during future module upgrades.
"""
_logger.info("Starting post-migration: Restoring noupdate flag.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's quite uncommon to be that verbose, but then it also doesn't really hurt

data file to prevent accidental data overwrites during future module upgrades.
"""
_logger.info("Starting post-migration: Restoring noupdate flag.")
api.Environment(cr, SUPERUSER_ID, {})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this statement does nothing

_logger.info(
"Post-migration successful: Restored noupdate='1' for %s.", xml_file_path
)
except Exception as e:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally, if some step of a migration script fails, the whole thing should fail, so the exception handling shouldn't be there at all.

if this code ever ran it would have also hidden all the things wrong with it


# Define the XML file to be reloaded. This is the same file that was temporarily
# changed in the pre-migration step.
xml_file_path = "l10n_nl_bank/data/res_bank_data.xml"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's wrong to pass the path of the module

Comment on lines +22 to +29
# Get the module name. This is crucial for a multi-module environment.
try:
module = env.ref("l10n_nl_bank").module
except ValueError:
_logger.error(
"Could not determine module name. Please check if 'l10n_nl_bank' exists."
)
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole section is nonsense and causes the script to exit early

Comment on lines +9 to +13
"""
This pre-migration script updates the XML ID for the Adyen bank
and temporarily sets noupdate="0" on the bank data file
to allow for a full data reload during the module upgrade.
"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of the above is true

mode="update",
noupdate=True,
kind="data",
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this call does not actually cause data to be overwritten, and fails anyways

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants