Skip to content

Commit

Permalink
Merge PR OCA#3250 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by renatonlima
  • Loading branch information
OCA-git-bot committed Jul 30, 2024
2 parents 42b8f02 + 9d79cc7 commit d765795
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions l10n_br_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,30 +1372,28 @@ def _nfe_cancel(self):
)

for retevento in processo.resposta.retEvento:
if not retevento.infEvento.chNFe == self.document_key:
continue

if retevento.infEvento.cStat not in CANCELADO:
mensagem = "Erro no cancelamento"
mensagem += "\nCódigo: " + retevento.infEvento.cStat
mensagem += "\nMotivo: " + retevento.infEvento.xMotivo
raise UserError(mensagem)

if retevento.infEvento.cStat == CANCELADO_FORA_PRAZO:
self.state_fiscal = SITUACAO_FISCAL_CANCELADO_EXTEMPORANEO
elif retevento.infEvento.cStat == CANCELADO_DENTRO_PRAZO:
self.state_fiscal = SITUACAO_FISCAL_CANCELADO

self.state_edoc = SITUACAO_EDOC_CANCELADA
self.cancel_event_id.set_done(
status_code=retevento.infEvento.cStat,
response=retevento.infEvento.xMotivo,
protocol_date=fields.Datetime.to_string(
datetime.fromisoformat(retevento.infEvento.dhRegEvento)
),
protocol_number=retevento.infEvento.nProt,
file_response_xml=processo.retorno.content.decode("utf-8"),
)
if retevento.infEvento.chNFe == self.document_key:
if retevento.infEvento.cStat == CANCELADO_FORA_PRAZO:
self.state_fiscal = SITUACAO_FISCAL_CANCELADO_EXTEMPORANEO
elif retevento.infEvento.cStat == CANCELADO_DENTRO_PRAZO:
self.state_fiscal = SITUACAO_FISCAL_CANCELADO

self.state_edoc = SITUACAO_EDOC_CANCELADA
self.cancel_event_id.set_done(
status_code=retevento.infEvento.cStat,
response=retevento.infEvento.xMotivo,
protocol_date=fields.Datetime.to_string(
datetime.fromisoformat(retevento.infEvento.dhRegEvento)
),
protocol_number=retevento.infEvento.nProt,
file_response_xml=processo.retorno.content.decode("utf-8"),
)

def _document_correction(self, justificative):
result = super()._document_correction(justificative)
Expand Down

0 comments on commit d765795

Please sign in to comment.