Skip to content

[16.0][ADD] l10n_br_fiscal: editable data mixin #3777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

rvalyi
Copy link
Member

@rvalyi rvalyi commented May 7, 2025

WORK IN PROGRESS

Rationale:

As for today many very large fiscal data are loaded via CSV or XML. Examples:

  • ncm
  • cnae
  • cfop
  • cest
  • nbs
  • tax.pis.cofins
  • fiscal.tax
  • cst

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:

  • Automatically creates ir.model.data entries for manually created records.
  • Provides get_records_without_xmlid() to find records lacking an XML ID.
  • Provides fill_missing_xml_ids() to backfill missing XML IDs for existing records.
  • Prevent writing values inconsistent with record xml_id.
  • Allow to toggle update/noupdate mode.

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.

@OCA-git-bot
Copy link
Contributor

Hi @renatonlima,
some modules you are maintaining are being modified, check this out!

@rvalyi rvalyi force-pushed the 16.0-editable-mixin branch 5 times, most recently from 1185019 to df8529d Compare May 7, 2025 16:32
@rvalyi rvalyi force-pushed the 16.0-editable-mixin branch from df8529d to e4423b7 Compare May 7, 2025 21:48
@rvalyi rvalyi marked this pull request as draft May 7, 2025 21:49
@rvalyi rvalyi closed this May 7, 2025
@rvalyi rvalyi force-pushed the 16.0-editable-mixin branch from e4423b7 to 36a1bd6 Compare May 7, 2025 23:57
@rvalyi rvalyi reopened this May 7, 2025
@OCA-git-bot
Copy link
Contributor

Hi @renatonlima,
some modules you are maintaining are being modified, check this out!

@antoniospneto
Copy link
Contributor

@rvalyi

Ainda não olhei a PR com atenção, mas pretendo revisar, apenas uma observação por enquanto:

Nesses casos a tag pra por no commit é [IMP] ou [REF]
[ADD] é somente quando é módulo novo:
https://www.odoo.com/documentation/16.0/contributing/development/git_guidelines.html#tag-and-module-name

@rvalyi rvalyi force-pushed the 16.0-editable-mixin branch 4 times, most recently from 81dbb5e to 7f08a08 Compare May 8, 2025 13:18
@rvalyi rvalyi force-pushed the 16.0-editable-mixin branch 5 times, most recently from 78a386c to 515e885 Compare May 8, 2025 16:08
@rvalyi rvalyi force-pushed the 16.0-editable-mixin branch from 515e885 to cdcbffe Compare May 8, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants