Skip to content

[16.0] l10n_br_fiscal fixes + docstring love #3789

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 7 commits into
base: 16.0
Choose a base branch
from

Conversation

rvalyi
Copy link
Member

@rvalyi rvalyi commented May 12, 2025

Some global AI assisted review of the main l10n_br_fiscal files. I carefully added docstrings to:

  • the largest classes
  • the most used classes
  • the key public methods

I could also fix small bugs in the process.

The idea is to lower the entry barrier to new comers to what is currently the largest f the 3000 OCA modules...

@OCA-git-bot
Copy link
Contributor

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

@rvalyi rvalyi marked this pull request as draft May 12, 2025 01:47
@rvalyi rvalyi force-pushed the 16.0-fiscal-fixes branch 2 times, most recently from a24e690 to 8f6c42f Compare May 12, 2025 03:48
@rvalyi rvalyi force-pushed the 16.0-fiscal-fixes branch 4 times, most recently from 9153f1e to 71afbb7 Compare May 12, 2025 14:02
Comment on lines 698 to 724
@api.onchange("fiscal_operation_id")
def _onchange_fiscal_operation_id(self):
# Call the super method from document.mixin.methods.
# This will handle:
# - Setting self.fiscal_operation_type
# - Setting self.edoc_purpose
# - Rebuilding self.document_subsequent_ids using odoo.fields.Command
result = super()._onchange_fiscal_operation_id()

# Specific logic for document.py after super() has run.
# The assignments to fiscal_operation_type and edoc_purpose might be
# redundant now if super() handles them comprehensively.
# Review if these are still needed or if super() is sufficient.
if self.fiscal_operation_id:
# If super() already sets these based on self.fiscal_operation_id,
# these lines might not be strictly necessary unless there's a reason
# for them to be re-set or set differently in this child class.
self.fiscal_operation_type = self.fiscal_operation_id.fiscal_operation_type
self.edoc_purpose = self.fiscal_operation_id.edoc_purpose

if self.issuer == DOCUMENT_ISSUER_COMPANY and not self.document_type_id:
# This logic for setting document_type_id seems specific to
# 'document.py' context (e.g., based on 'self.issuer' which
# might be a field on 'document.py' or its mixins).
# Keep this if it's not handled by the mixin or needs to be
# explicitly here.
if (
self.fiscal_operation_id
and self.issuer == DOCUMENT_ISSUER_COMPANY
and not self.document_type_id
): # Only set if not already set
self.document_type_id = self.company_id.document_type_id

subsequent_documents = [(6, 0, {})]
for subsequent_id in self.fiscal_operation_id.mapped(
"operation_subsequent_ids"
):
subsequent_documents.append(
(
0,
0,
{
"source_document_id": self.id,
"subsequent_operation_id": subsequent_id.id,
"fiscal_operation_id": subsequent_id.subsequent_operation_id.id,
},
)
)
self.document_subsequent_ids = subsequent_documents
# The logic for rebuilding 'document_subsequent_ids' with tuple commands
# has been removed from here. The super() call now handles this using
# odoo.fields.Command via the updated mixin method.

return result
Copy link
Contributor

Choose a reason for hiding this comment

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

Acho que não tá legal, é muito comentário pra pouco código

Documentar é importante, mas sem exagero. Comentários muito longos tornam o código mais difícil de manter, porque exigem que a gente fique sempre conferindo se ainda estão alinhados com o que o código faz.

Copy link
Member Author

@rvalyi rvalyi May 12, 2025

Choose a reason for hiding this comment

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

essa parte dos onchanges foi o Gemini que pegou uns bugs e propois esse refator. Deixei comentado porque ele comentou as duvidas que ficaram. Deixei apenas para a gente rever mesmo... Por isso o PR em rascunho mesmo...

Do restante fora esse onchange da Kmee com as operações subsequentes (sem teste para variar...) ele não achou muita coisa zoada não, o que é um sinal bastante bom e que eu queria checar antes de jogar o modulo para a 17.0...

Copy link
Member Author

@rvalyi rvalyi May 12, 2025

Choose a reason for hiding this comment

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

disclaimer: Eu não botei para revisar o res_company.py onde sabemos que a Kmee extrapolou muito nas questões das taxas efetivas e que ta sem teste. Mas como vcs @antoniospneto e @renatonlima tavam refartorando e botando testes, eu pensei que não adiantava revisar o código atual disso.

Copy link
Contributor

Choose a reason for hiding this comment

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

entendi só pra validar se a alteração que ele fez faz sentido

@rvalyi rvalyi force-pushed the 16.0-fiscal-fixes branch 5 times, most recently from efb4147 to 748fa4e Compare May 19, 2025 21:32
@rvalyi rvalyi force-pushed the 16.0-fiscal-fixes branch from 748fa4e to ffa4cc6 Compare May 19, 2025 21:34
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