Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] l10n_br_fiscal, l10n_br_nfe: Melhorias na transmissão da NF-e (v2) #3081

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions l10n_br_account_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def _check_fiscal_payment_mode(self):
)
)

def _process_document_in_contingency(self):
super()._process_document_in_contingency()
def _update_nfce_for_offline_contingency(self):
super()._update_nfce_for_offline_contingency()

if self.move_ids:
copy_invoice = self.move_ids[0].copy()
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_account_nfe/tests/test_nfce_contingency.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ def prepare_account_move_nfce(self):
self.document_move_id.fiscal_document_id = self.document_id.id

def test_nfce_contingencia(self):
self.document_id._process_document_in_contingency()
self.document_id._update_nfce_for_offline_contingency()

self.assertIn(self.document_move_id, self.document_id.move_ids)
4 changes: 2 additions & 2 deletions l10n_br_fiscal/constants/fiscal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

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
Loading
Loading