Skip to content

[16.0][l10n_br_fiscal][l10n_br_hr] fields.Text -> fields.Char where possible #3787

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

Closed
wants to merge 2 commits into from

Conversation

rvalyi
Copy link
Member

@rvalyi rvalyi commented May 10, 2025

convert fields.Text to fields.Char where it makes sense.

Feature fields.Char fields.Text
Max Length 256 chars (configurable with size) Unlimited
Database Type VARCHAR(size) TEXT
Use Case Short strings (names, codes, emails) Long, multiline text (descriptions)
Supports Newlines ❌ No (single-line) ✅ Yes (\n works)
Performance ✅ Slightly faster (fixed-size) ⚠️ Slightly slower (variable-size)
Example name = fields.Char(size=100) notes = fields.Text()

@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-text-to-char branch from d87f9e6 to e4f3bf1 Compare May 10, 2025 19:48
@rvalyi rvalyi changed the title [16.0][l10n_br_fiscal][l10n_br_hr] 16.0 text to char [16.0][l10n_br_fiscal][l10n_br_hr] fields.Text -> fields.Char where possible May 10, 2025
@rvalyi rvalyi force-pushed the 16.0-text-to-char branch from e4f3bf1 to 5f3d0d6 Compare May 11, 2025 01:16
@rvalyi
Copy link
Member Author

rvalyi commented May 12, 2025

Na verdade eu acabei de checar num banco de prod 14.0 e NCM e CEST tem name mais longos do que 256 chars (3x mais!) então parece que não poderiamos alterar para esses:


odoo14=> SELECT
    MAX(CHAR_LENGTH(name)) AS max_length,
    CASE
        WHEN MAX(CHAR_LENGTH(name)) <= 256 THEN 'Convertible to VARCHAR(256)'
        ELSE 'Cannot convert - exceeds 256 characters'
    END AS conversion_status
FROM l10n_br_fiscal_ncm;
 max_length |            conversion_status
------------+-----------------------------------------
       1159 | Cannot convert - exceeds 256 characters
(1 row)

odoo14=> SELECT
    MAX(CHAR_LENGTH(name)) AS max_length,
    CASE
        WHEN MAX(CHAR_LENGTH(name)) <= 256 THEN 'Convertible to VARCHAR(256)'
        ELSE 'Cannot convert - exceeds 256 characters'
    END AS conversion_status
FROM l10n_br_fiscal_cest;
 max_length |            conversion_status
------------+-----------------------------------------
        601 | Cannot convert - exceeds 256 characters
(1 row)

@rvalyi rvalyi marked this pull request as draft May 12, 2025 17:08
@rvalyi
Copy link
Member Author

rvalyi commented May 12, 2025

dessas mudanças que eu propois aqui, daria para reduzir aprenas para NBM ou icms_regulation. Vamos pensar melhor mas talvez não der para mudar no data_abstract mesmo, ou digamos que não valeria a pena.

cc @renatonlima

@rvalyi
Copy link
Member Author

rvalyi commented May 12, 2025

substituído então por #3791

@rvalyi rvalyi closed this May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants