diff --git a/l10n_br_fiscal_edi/models/document_event.py b/l10n_br_fiscal_edi/models/document_event.py index 6e167372425d..28076b54e3da 100644 --- a/l10n_br_fiscal_edi/models/document_event.py +++ b/l10n_br_fiscal_edi/models/document_event.py @@ -222,8 +222,11 @@ def _save_event_2disk(self, arquivo, file_name): numero = self.document_number if self.document_id: - ano = self.document_id.document_date.strftime("%Y") - mes = self.document_id.document_date.strftime("%m") + document_date = ( + self.document_id.document_date or self.document_id.create_date + ) + ano = document_date.strftime("%Y") + mes = document_date.strftime("%m") elif self.invalidate_number_id: ano = self.invalidate_number_id.date.strftime("%Y") mes = self.invalidate_number_id.date.strftime("%m")