From 0fd1a428be816f5e709b5a119eb941289ccb8fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Neto?= Date: Tue, 28 May 2024 21:56:36 -0300 Subject: [PATCH 1/4] [REF] l10n_br_fiscal: fix typos; improve wording --- l10n_br_fiscal/constants/fiscal.py | 4 ++-- l10n_br_fiscal/models/document_event.py | 4 ++-- l10n_br_fiscal/views/document_event_view.xml | 1 + l10n_br_fiscal/views/document_view.xml | 9 ++------- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/l10n_br_fiscal/constants/fiscal.py b/l10n_br_fiscal/constants/fiscal.py index f572f436b869..fcd0cd468d59 100644 --- a/l10n_br_fiscal/constants/fiscal.py +++ b/l10n_br_fiscal/constants/fiscal.py @@ -351,11 +351,11 @@ ] AUTORIZADO = ("100", "150") -DENEGADO = ("110", "301", "302") +DENEGADO = ("110", "301", "302", "303") LOTE_RECEBIDO = ["103"] LOTE_PROCESSADO = ["104"] LOTE_EM_PROCESSAMENTO = ["105"] -CONTINGENCIA = ("108", "109") +SERVICO_PARALIZADO = ("108", "109") CANCELAMENTO_HOMOLOGADO = ["101", "151"] diff --git a/l10n_br_fiscal/models/document_event.py b/l10n_br_fiscal/models/document_event.py index d613ce041e9f..398f790938f9 100644 --- a/l10n_br_fiscal/models/document_event.py +++ b/l10n_br_fiscal/models/document_event.py @@ -69,7 +69,7 @@ def _compute_display_name(self): type = fields.Selection( selection=[ ("-1", "Exception"), - ("0", "Envio Lote"), + ("0", "Autorização de Uso"), ("1", "Consulta Recibo"), ("2", "Cancelamento"), ("3", "Inutilização"), @@ -300,7 +300,7 @@ def _save_event_file( ) if authorization: - # Nâo deletamos um aquivo de autorização já + # Não deletamos um aquivo de autorização já # Existente por segurança self.file_response_id = False self.file_response_id = attachment_id diff --git a/l10n_br_fiscal/views/document_event_view.xml b/l10n_br_fiscal/views/document_event_view.xml index b72801e17cde..27f820b6d131 100644 --- a/l10n_br_fiscal/views/document_event_view.xml +++ b/l10n_br_fiscal/views/document_event_view.xml @@ -50,6 +50,7 @@ + diff --git a/l10n_br_fiscal/views/document_view.xml b/l10n_br_fiscal/views/document_view.xml index 1a2f2a43d9bc..8f1ae46f288e 100644 --- a/l10n_br_fiscal/views/document_view.xml +++ b/l10n_br_fiscal/views/document_view.xml @@ -89,7 +89,6 @@
- @@ -171,10 +170,6 @@ groups="l10n_br_fiscal.group_user" attrs="{'invisible': [('state_edoc', 'not in', ('autorizada', 'cancelada', 'denegada'))]}" /> - - - - @@ -451,7 +446,7 @@ - + From 2d1502adf8ead3b1bec336e11eacd43fbd2c546d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Neto?= Date: Tue, 28 May 2024 22:35:15 -0300 Subject: [PATCH 2/4] [IMP] l10n_br_fiscal: adds support for sync communcation --- l10n_br_fiscal/models/document_event.py | 10 +++++++++- l10n_br_fiscal/models/document_workflow.py | 6 ++++-- l10n_br_fiscal/views/document_view.xml | 10 +++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/l10n_br_fiscal/models/document_event.py b/l10n_br_fiscal/models/document_event.py index 398f790938f9..f6bd5231d20d 100644 --- a/l10n_br_fiscal/models/document_event.py +++ b/l10n_br_fiscal/models/document_event.py @@ -185,6 +185,13 @@ def _compute_display_name(self): protocol_number = fields.Char() + lot_receipt_number = fields.Char( + help=( + "In asynchronous processing, a lot receipt number is generated, " + "which is used for later consultation." + ), + ) + state = fields.Selection( selection=[ ("draft", _("Draft")), @@ -312,7 +319,8 @@ def _save_event_file( def set_done( self, status_code, response, protocol_date, protocol_number, file_response_xml ): - self._save_event_file(file_response_xml, "xml", authorization=True) + if file_response_xml: + self._save_event_file(file_response_xml, "xml", authorization=True) self.write( { "state": "done", diff --git a/l10n_br_fiscal/models/document_workflow.py b/l10n_br_fiscal/models/document_workflow.py index 9491baa45bfc..8ee3f9d966e7 100644 --- a/l10n_br_fiscal/models/document_workflow.py +++ b/l10n_br_fiscal/models/document_workflow.py @@ -199,7 +199,7 @@ def _after_change_state(self, old_state, new_state): self._generates_subsequent_operations() - def _change_state(self, new_state): + def _change_state(self, new_state, force_change=False): """Método para alterar o estado do documento fiscal, mantendo a integridade do workflow da invoice. @@ -215,7 +215,9 @@ def _change_state(self, new_state): for record in self: old_state = record.state_edoc - if not record._avaliable_transition(old_state, new_state): + if force_change or record._avaliable_transition(old_state, new_state): + pass + else: raise UserError( _( "Não é possível realizar esta operação,\n" diff --git a/l10n_br_fiscal/views/document_view.xml b/l10n_br_fiscal/views/document_view.xml index 8f1ae46f288e..c90641fa15ea 100644 --- a/l10n_br_fiscal/views/document_view.xml +++ b/l10n_br_fiscal/views/document_view.xml @@ -109,7 +109,15 @@ string="Enviar" groups="l10n_br_fiscal.group_user" class="btn-primary" - attrs="{'invisible': [('state_edoc', 'not in', ('a_enviar', 'rejeitada'))]}" + attrs="{'invisible': [('state_edoc','!=','a_enviar')]}" + /> +