Skip to content

Commit

Permalink
[IMP] l10n_br_fiscal: some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed May 10, 2024
1 parent 2044888 commit eb07db6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion l10n_br_fiscal/constants/fiscal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
14 changes: 11 additions & 3 deletions l10n_br_fiscal/models/document_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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")),
Expand Down Expand Up @@ -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
Expand All @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions l10n_br_fiscal/models/document_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions l10n_br_fiscal/views/document_event_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<field name="file_request_id" />
<field name="file_response_id" />
<field name="protocol_number" />
<field name="lot_receipt_number" />
<field name="response" />
<field name="origin" />
<field name="write_date" />
Expand Down
19 changes: 11 additions & 8 deletions l10n_br_fiscal/views/document_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
<field name="arch" type="xml">
<form string="Fiscal Document">
<field name="id" invisible="1" />
<!-- <field name="state_edoc" invisible="1"/>-->
<field name="currency_id" invisible="1" />
<field name="document_electronic" invisible="1" />
<field name="fiscal_operation_type" invisible="1" />
Expand All @@ -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')]}"
/>
<button
name="action_document_send"
type="object"
string="Consultar Recibo"
groups="l10n_br_fiscal.group_user"
class="btn-primary"
attrs="{'invisible': [('state_edoc','!=','enviada')]}"
/>
<button
name="action_document_back2draft"
Expand Down Expand Up @@ -171,10 +178,6 @@
groups="l10n_br_fiscal.group_user"
attrs="{'invisible': [('state_edoc', 'not in', ('autorizada', 'cancelada', 'denegada'))]}"
/>
<!-- <button name="action_edoc_check" type="object"-->
<!-- string="Consultar no sefaz"-->
<!-- groups="base.group_no_one"/>-->
<!-- -->
<field
name="state_edoc"
widget="statusbar"
Expand Down Expand Up @@ -421,7 +424,7 @@
</group>
<group
name="cancel"
string="Cancelation"
string="Cancellation"
colspan="4"
attrs="{'invisible': [('state_edoc', '!=', 'cancelada')]}"
>
Expand Down Expand Up @@ -451,7 +454,7 @@
</tree>
</field>
</group>
<group name="events" string="Events" colspan="4">
<group name="events" string="Events and Services" colspan="4">
<field name="event_ids" nolabel="1">
<tree>
<field name="id" />
Expand Down

0 comments on commit eb07db6

Please sign in to comment.