From 6bf534c248a9e52de520514e4e887f2a8fd7b16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Neto?= Date: Thu, 7 Mar 2024 22:46:56 -0300 Subject: [PATCH 1/2] [IMP] l10n_br_fiscal: some improvements --- l10n_br_fiscal/constants/fiscal.py | 2 +- l10n_br_fiscal/models/document_event.py | 14 +++++++++++--- l10n_br_fiscal/models/document_workflow.py | 6 ++++-- l10n_br_fiscal/views/document_event_view.xml | 1 + l10n_br_fiscal/views/document_view.xml | 19 +++++++++++-------- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/l10n_br_fiscal/constants/fiscal.py b/l10n_br_fiscal/constants/fiscal.py index f572f436b869..ad516eb993fd 100644 --- a/l10n_br_fiscal/constants/fiscal.py +++ b/l10n_br_fiscal/constants/fiscal.py @@ -355,7 +355,7 @@ 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..f6bd5231d20d 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"), @@ -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")), @@ -300,7 +307,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 @@ -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_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..c90641fa15ea 100644 --- a/l10n_br_fiscal/views/document_view.xml +++ b/l10n_br_fiscal/views/document_view.xml @@ -89,7 +89,6 @@
- @@ -110,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')]}" + /> +