[16.0][ADD] l10n_br_fiscal: editable data mixin #3777
Draft
+747
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WORK IN PROGRESS
Rationale:
As for today many very large fiscal data are loaded via CSV or XML. Examples:
Because these files can be so huge, we often load them with noupdate=True (we even monkey_patched convert_csv_import for this) to avoid long minutes of updates in production.
Also historically these files were poorly maintained. So when Akretion had a big customer, we would maintain their data for their specific operations, but don't really bother maintaining these files up to date. This is now changing with more serious projects in production and more serious contributors participating.
A problem with these data is when a user wants to update some value manually or create a new record (like a new NCM that was missing). These records will have no xml_id or ir.model.data entry. And later when we try to update or migrate the database, the new records that would eventually be inserted in the source csv or XML files would clash with these manually entered records in the database making the whole upgrade process cumbersome.
So I introduced a new mixin here that will fix this by providing these features:
get_records_without_xmlid()
to find records lacking an XML ID.fill_missing_xml_ids()
to backfill missing XML IDs for existing records.NOTE: some of the mixin code has been proposed by the Gemini AI (I'm still adjusting it) and most of the tests were written by the AI. This worked because this code is quite independent from the localization code.