Skip to content
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

[16.0][FIX] l10n_br_fiscal_edi: Evita erro por chamar o método back2draft duas vezes #3611

Conversation

mbcosta
Copy link
Contributor

@mbcosta mbcosta commented Feb 4, 2025

Avoid call back2draft twice.

Evita erro por chamar o método back2draft duas vezes, esse erro apareceu no PR de migração do l10n_br_delivery aqui

https://github.com/OCA/l10n-brazil/actions/runs/13035384911/job/36364402057?pr=3571#step:9:2768

2025-01-29 16:13:39,084 701 ERROR odoo odoo.addons.l10n_br_account.tests.test_account_move_lc: ERROR: AccountMoveLucroPresumido.test_change_states
Traceback (most recent call last):
  File "/opt/odoo-venv/lib/python3.10/site-packages/odoo/addons/l10n_br_account/tests/test_account_move_lc.py", line 1732, in test_change_states
    document_id.action_document_back2draft()
  File "/__w/l10n-brazil/l10n-brazil/l10n_br_fiscal_edi/models/document.py", line 186, in action_document_back2draft
    return self._action_document_back2draft()
  File "/__w/l10n-brazil/l10n-brazil/l10n_br_fiscal_edi/models/document_workflow.py", line 330, in _action_document_back2draft
    self.document_back2draft()
  File "/__w/l10n-brazil/l10n-brazil/l10n_br_fiscal_edi/models/document_workflow.py", line 325, in document_back2draft
    self._change_state(SITUACAO_EDOC_EM_DIGITACAO)
  File "/__w/l10n-brazil/l10n-brazil/l10n_br_fiscal_edi/models/document_workflow.py", line 209, in _change_state
    raise UserError(
odoo.exceptions.UserError: Não é possível realizar esta operação,
esta transição não é permitida:

De: em_digitacao

 Para: em_digitacao

Pelos o que entendi antes de tentar alterar o state_edoc é feita uma validação https://github.com/OCA/l10n-brazil/blob/16.0/l10n_br_account/tests/test_account_move_lc.py#L1731 e o state_edoc está como a_enviar mas ao chamar action_document_back2draft o programa tentar alterar o campo duas vezes e na segunda retorna erro porque o campo já foi alterado, acredito que ao chamar o https://github.com/OCA/l10n-brazil/blob/16.0/l10n_br_account/models/document.py#L209 o método button_draft do account.move já é feita a alteração aqui https://github.com/OCA/l10n-brazil/blob/16.0/l10n_br_account/models/account_move.py#L514 e na sequencia de de chamadas do super() quando chega aqui https://github.com/OCA/l10n-brazil/blob/16.0/l10n_br_fiscal_edi/models/document_workflow.py#L325 o state_edoc já foi alterado.

Não sei porque esse erro não apareceu antes, talvez porque o CI instala alguns módulos da localização antes no caso do l10n_br_delivery? Mas a alteração é simples não deve causar nenhum erro, é semelhante com o que já é feito no button_draft um filtered evita o erro.

cc @OCA/local-brazil-maintainers

@rvalyi
Copy link
Member

rvalyi commented Feb 6, 2025

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-3611-by-rvalyi-bump-patch, awaiting test results.

@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at c41f57f. Thanks a lot for contributing to OCA. ❤️

@OCA-git-bot OCA-git-bot merged commit e2e1527 into OCA:16.0 Feb 6, 2025
6 checks passed
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.

6 participants