Skip to content
Health
90/100
good
  • Security25/25
    No findings
  • Activity25/25
    Human commit this month
  • Required by15/25
    1 module depends on it
  • Maturity25/25
    In 6 Odoo series since 14.0

Heuristic over the facts below, not an audit · How it's computed

Security findings
Grave / minor (static analysis)
Required by
1
Modules depending on it
External deps
6 pip · 0 bin
Python packages / system binaries
License
AGPL-3
No conflicts with its dependencies
Folder size
0.29 MB
Module directory on disk
Code analysis 0 migration notes 9 models 13 views 0 HTTP endpoints

Description

Este módulo fornece a infraestrutura base para o Intercâmbio Eletrônico de Dados (EDI) de documentos fiscais brasileiros no Odoo.

Ele implementa uma Máquina de Estados Finitos (FSM - Finite State Machine) para gerenciar o ciclo de vida dos documentos fiscais eletrônicos (NF-e, NFC-e, NFS-e, CT-e, MDF-e etc.), garantindo integridade, consistência e rastreabilidade das transições de estado.

Principais Características

  • Máquina de Estados (FSM): controle rigoroso das transições de estado (por exemplo, de draft para open, depois para sending e finalmente para authorized, rejected ou denied), com bloqueio de movimentos inválidos.
  • Configuração extensível por documento: a FSM base é definida no método get_state_machine_config() e pode ser sobrescrita por módulos específicos de documento fiscal para ajustar estados, transições e callbacks.
  • Gerenciamento de Eventos: arquitetura para suportar eventos fiscais vinculados ao documento, como Cancelamento, Carta de Correção Eletrônica (CC-e) e Inutilização de Numeração.
  • Abstração de Protocolo: separa a lógica de negócios da lógica de comunicação. Módulos específicos (como l10n_br_nfe ou l10n_br_nfse) herdam deste módulo para implementar a integração com webservices (SEFAZ/Prefeituras), enquanto o l10n_br_fiscal_edi orquestra o fluxo.
  • Interface Padronizada: oferece uma experiência consistente com botões e ações uniformes, independentemente do modelo de documento fiscal.

Workflow de Estados

O diagrama abaixo ilustra os estados e transições padrão definidos no módulo base (a configuração pode ser estendida/sobrescrita por módulos filhos):

FSM state diagram

Dependencies

Odoo dependencies
OCA/l10n-brazil:
OCA/product-attribute:
odoo/odoo:
- web
- bus
- uom
Python dependencies
transitions, erpbrasil-base>=2.4.2, xsdata, email-validator, num2words, phonenumbers
System dependencies
None
Required by
l10n_br_nfse

Code analysis

Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.

Views touched 13

XML IDNameModelTypeStatus
document_cancel_wizard_form l10n_br_fiscal.document.cancel.wizard l10n_br_fiscal.document.cancel.wizard form New
document_correction_wizard_form l10n_br_fiscal.document.correction.wizard.form l10n_br_fiscal.document.correction.wizard form New
document_form l10n_br_fiscal_edi.document.form l10n_br_fiscal.document form Inherits l10n_br_fiscal.document_form
document_search l10n_br_fiscal_edi.document.search l10n_br_fiscal.document search Inherits l10n_br_fiscal.document_search
document_tree l10n_br_fiscal_edi.document.tree l10n_br_fiscal.document list Inherits l10n_br_fiscal.document_tree
event_form l10n_br_fiscal.event.form l10n_br_fiscal.event form New
event_search l10n_br_fiscal.event.search l10n_br_fiscal.event search New
event_tree l10n_br_fiscal.event.tree l10n_br_fiscal.event list New
invalidate_number_form l10n_br_fiscal_edi.invalidate.number.form l10n_br_fiscal.invalidate.number form Inherits l10n_br_fiscal.invalidate_number_form
invalidate_number_wizard l10n_br_fiscal.invalidate.number.wizard l10n_br_fiscal.invalidate.number.wizard form New
main_report_document_event main_report_document_event ir.ui.view qweb New
report_document_event report_document_event ir.ui.view qweb New
wizard_document_status_form wizard.l10n_br_fiscal.base.wizard.mixin (in l10n_br_fiscal) l10n_br_fiscal.document.status.wizard form New

HTTP endpoints 0

No HTTP endpoints found for this module.

Models touched 9

New fields (1)
  • event_id Many2one → l10n_br_fiscal.event
    comodel_name='l10n_br_fiscal.event' string='Fiscal Event'
Public methods (0)

No public methods.

New fields (27)
  • authorization_date Datetime
    related='authorization_event_id.protocol_date' string='Authorization Protocol Date'
  • authorization_event_id Many2one → l10n_br_fiscal.event
    comodel_name='l10n_br_fiscal.event' copy=False readonly=True string='Authorization Event'
  • authorization_file_id Many2one → ir.attachment
    comodel_name='ir.attachment' ondelete='restrict' readonly=True related='authorization_event_id.file_response_id' string='Authorization File XML'
  • authorization_protocol Char
    related='authorization_event_id.protocol_number' string='Authorization Protocol Number'
  • cancel_date Datetime
    related='cancel_event_id.protocol_date' string='Cancel Protocol Date'
  • cancel_event_id Many2one → l10n_br_fiscal.event
    comodel_name='l10n_br_fiscal.event' copy=False string='Cancel Event'
  • cancel_file_id Many2one → ir.attachment
    comodel_name='ir.attachment' ondelete='restrict' readonly=True related='cancel_event_id.file_response_id' string='Cancel File XML'
  • cancel_protocol_number Char
    related='cancel_event_id.protocol_number' string='Cancel Protocol Protocol'
  • cancel_reason Char
  • correction_event_ids One2many → l10n_br_fiscal.event
    comodel_name='l10n_br_fiscal.event' copy=False domain=[('type', '=', '14')] inverse_name='document_id' readonly=True string='Correction Events'
  • correction_reason Char
  • document_version Char
    default='4.00' readonly=True string='Version'
  • event_ids One2many → l10n_br_fiscal.event
    comodel_name='l10n_br_fiscal.event' copy=False inverse_name='document_id' readonly=True string='Events'
  • file_report_id Many2one → ir.attachment
    comodel_name='ir.attachment' copy=False ondelete='restrict' readonly=True string='Document Report'
  • invalidate_date Datetime
    related='invalidate_event_id.protocol_date' string='Invalidate Protocol Date'
  • invalidate_event_id Many2one → l10n_br_fiscal.event
    comodel_name='l10n_br_fiscal.event' copy=False string='Invalidate Event'
  • invalidate_file_id Many2one → ir.attachment
    comodel_name='ir.attachment' ondelete='restrict' readonly=True related='invalidate_event_id.file_response_id' string='Invalidate File XML'
  • invalidate_protocol_number Char
    related='invalidate_event_id.protocol_number' string='Invalidate Protocol Number'
  • is_edoc_printed Boolean
    readonly=True string='Is Printed?'
  • issuer Selection
    default=DOCUMENT_ISSUER_COMPANY selection=DOCUMENT_ISSUER
  • original_xml_file_id Many2one → ir.attachment
    comodel_name='ir.attachment' copy=False help='XML of a document issued by a third party, kept as received when the document is imported. It is not an authorization event.' readonly=True string='Original XML File'
  • send_file_id Many2one → ir.attachment
    comodel_name='ir.attachment' ondelete='restrict' readonly=True related='authorization_event_id.file_request_id' string='Send Document File XML'
  • state_edoc Selection
    ondelete={DOCUMENT_STATE_SENDING: 'set default', DOCUMENT_STATE_AUTHORIZED: 'set default', DOCUMENT_STATE_REJECTED: 'set default', DOCUMENT_STATE_DENIED: 'set default'} selection_add=DOCUMENT_STATES
  • status_code Char
    copy=False
  • status_description Char
    compute='_compute_status_description' copy=False
  • status_name Char
    copy=False
  • xml_error_message Text
    copy=False readonly=True string='XML validation errors'
Public methods (12)
  • action_check_status(self)
    Ask the SEFAZ about each selected document, within a safe batch size.
  • action_document_back2draft(self)
    Override base button
  • action_document_cancel(self)
    Override base button
  • action_document_confirm(self)
    Override base button to trigger FSM validation. This method must be idempotent because account.move._post() may call it again for already confirmed documents. - Electronic company-issued docs: draft -> open (action_validate), then optionally send if _direct_draft_send(). - Non-electronic company docs: draft -> authorized (action_authorize), skipping the sending step since there is nothing to transmit. - Partner-issued docs (imported supplier NF-e): draft -> authorized (action_authorize), since they are already authorized externally. All paths go through _before_document_validate (numbering, date, operation comments) to avoid the regression where non-electronic and partner docs were confirmed without numbering.
  • action_document_correction(self)
    Open the correction wizard for authorized company-issued documents.
  • action_document_invalidate(self)
    Open the number invalidation wizard for company-issued documents that are in a state where the number was consumed but the document can still be invalidated (rejected/denied).
  • action_document_send(self)
    Trigger Sending
  • get_state_machine_config(self)
  • make_pdf(self)
  • serialize(self)
    Serialize the document to a list of EDocs (objects from erpbrasil.edoc). Modules should override _serialize to add their EDocs.
  • view_pdf(self)
  • view_xml(self)

New fields (0)

No new fields.

Public methods (2)
  • do_cancel(self)
  • doit(self)

New fields (0)

No new fields.

Public methods (1)
  • doit(self)

New fields (0)

No new fields.

Public methods (0)

No public methods.

New fields (25)
  • company_id Many2one → res.company
    comodel_name='res.company' index=True required=True string='Company'
  • create_date Datetime
    default=fields.Datetime.now index=True readonly=True
  • display_name Char
    compute='_compute_display_name' store=True string='name'
  • document_id Many2one → l10n_br_fiscal.document
    comodel_name='l10n_br_fiscal.document' index=True string='Fiscal Document'
  • document_number Char
    required=True
  • document_serie_id Many2one → l10n_br_fiscal.document.serie
    comodel_name='l10n_br_fiscal.document.serie' required=True
  • document_type_id Many2one → l10n_br_fiscal.document.type
    comodel_name='l10n_br_fiscal.document.type' index=True required=True string='Fiscal Document Type'
  • environment Selection
    selection=EVENT_ENVIRONMENT
  • file_path Char
    readonly=True
  • file_request_id Many2one → ir.attachment
    comodel_name='ir.attachment' copy=False readonly=True string='XML'
  • file_response_id Many2one → ir.attachment
    comodel_name='ir.attachment' copy=False readonly=True string='XML Response'
  • invalidate_number_id Many2one → l10n_br_fiscal.invalidate.number
    comodel_name='l10n_br_fiscal.invalidate.number' index=True string='Invalidate Number'
  • justification Char
  • lot_receipt_number Char
    help='In asynchronous processing, a lot receipt number is generated, which is used for later consultation.'
  • message Char
    readonly=True
  • origin Char
    help='Document reference that generated this event.' readonly=True string='Source Document'
  • partner_id Many2one → res.partner
    comodel_name='res.partner' index=True string='Partner'
  • protocol_date Datetime
    index=True readonly=True
  • protocol_number Char
  • response Char
    readonly=True string='Response Message'
  • sequence Char
    help='Fiscal Document Event Sequence'
  • state Selection
    default='draft' index=True readonly=True selection=[('draft', 'Draft'), ('send', 'Sending'), ('wait', 'Waiting Response'), ('done', 'Response received')] string='Status'
  • status_code Char
    readonly=True
  • type Selection
    selection=[('-1', 'Exception'), ('0', 'Autorização de Uso'), ('1', 'Consulta Recibo'), ('2', 'Cancelamento'), ('3', 'Inutilização'), ('4', 'Consulta NFE'), ('5', 'Consulta Situação'), ('6', 'Consulta Cadastro'), ('7', 'DPEC Recepção'), ('8', 'DPEC Consulta'), ('9', 'Recepção Evento'), ('10', 'Download'), ('11', 'Consulta Destinadas'), ('12', 'Distribuição DFe'), ('13', 'Manifestação'), ('14', 'Carta de Correção')] string='Service'
  • write_date Datetime
    index=True readonly=True
Public methods (3)
  • create_event_save_xml(self, company_id, environment, event_type, xml_file, document_id=False, invalidate_number_id=False, sequence=False, justification=False)
  • print_document_event(self)
  • set_done(self, status_code, response, protocol_date, protocol_number, file_response_xml)

New fields (6)
  • authorization_date Datetime
    related='authorization_event_id.protocol_date' string='Authorization Date'
  • authorization_event_id Many2one → l10n_br_fiscal.event
    comodel_name='l10n_br_fiscal.event' copy=False readonly=True string='Authorization Event'
  • authorization_file_id Many2one → ir.attachment
    comodel_name='ir.attachment' ondelete='restrict' related='authorization_event_id.file_response_id' string='Authorization File XML'
  • authorization_protocol Char
    related='authorization_event_id.protocol_number' string='Authorization Protocol'
  • event_ids One2many → l10n_br_fiscal.event
    comodel_name='l10n_br_fiscal.event' inverse_name='invalidate_number_id' readonly=True string='Events'
  • send_file_id Many2one → ir.attachment
    comodel_name='ir.attachment' ondelete='restrict' related='authorization_event_id.file_request_id' string='Send Document File XML'
Public methods (0)

No public methods.

New fields (0)

No new fields.

Public methods (2)
  • do_invalidate(self)
  • doit(self)

New fields (0)

No new fields.

Public methods (0)

No public methods.

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…