Skip to content

Commit

Permalink
[IMP] l10n_br_fiscal: adds support for sync communcation
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed May 29, 2024
1 parent 0fd1a42 commit 2d1502a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
10 changes: 9 additions & 1 deletion l10n_br_fiscal/models/document_event.py
Original file line number Diff line number Diff line change
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 @@ -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
10 changes: 9 additions & 1 deletion l10n_br_fiscal/views/document_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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')]}"
/>
<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

0 comments on commit 2d1502a

Please sign in to comment.