odoo-addon-l10n-br-fiscal-edi 15.0.1.0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/l10n_br_fiscal_edi/README.rst +124 -0
- odoo/addons/l10n_br_fiscal_edi/__init__.py +2 -0
- odoo/addons/l10n_br_fiscal_edi/__manifest__.py +41 -0
- odoo/addons/l10n_br_fiscal_edi/i18n/l10n_br_fiscal_edi.pot +896 -0
- odoo/addons/l10n_br_fiscal_edi/models/__init__.py +4 -0
- odoo/addons/l10n_br_fiscal_edi/models/document.py +294 -0
- odoo/addons/l10n_br_fiscal_edi/models/document_event.py +392 -0
- odoo/addons/l10n_br_fiscal_edi/models/document_workflow.py +387 -0
- odoo/addons/l10n_br_fiscal_edi/models/invalidate_number.py +53 -0
- odoo/addons/l10n_br_fiscal_edi/readme/CONTRIBUTORS.md +5 -0
- odoo/addons/l10n_br_fiscal_edi/readme/DESCRIPTION.md +6 -0
- odoo/addons/l10n_br_fiscal_edi/readme/ROADMAP.md +6 -0
- odoo/addons/l10n_br_fiscal_edi/readme/USAGE.md +7 -0
- odoo/addons/l10n_br_fiscal_edi/security/ir.model.access.csv +7 -0
- odoo/addons/l10n_br_fiscal_edi/static/description/icon.png +0 -0
- odoo/addons/l10n_br_fiscal_edi/static/description/index.html +460 -0
- odoo/addons/l10n_br_fiscal_edi/tests/__init__.py +1 -0
- odoo/addons/l10n_br_fiscal_edi/tests/test_fiscal_document_generic.py +1191 -0
- odoo/addons/l10n_br_fiscal_edi/tests/test_tax_benefit.py +74 -0
- odoo/addons/l10n_br_fiscal_edi/tests/test_workflow.py +118 -0
- odoo/addons/l10n_br_fiscal_edi/views/document_event_report.xml +15 -0
- odoo/addons/l10n_br_fiscal_edi/views/document_event_template.xml +114 -0
- odoo/addons/l10n_br_fiscal_edi/views/document_event_view.xml +68 -0
- odoo/addons/l10n_br_fiscal_edi/views/document_view.xml +77 -0
- odoo/addons/l10n_br_fiscal_edi/views/invalidate_number_view.xml +19 -0
- odoo/addons/l10n_br_fiscal_edi/views/l10n_br_fiscal_action.xml +38 -0
- odoo/addons/l10n_br_fiscal_edi/views/l10n_br_fiscal_menu.xml +23 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/__init__.py +7 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/base_wizard_mixin.py +13 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/document_cancel_wizard.py +20 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/document_cancel_wizard.xml +30 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/document_correction_wizard.py +17 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/document_correction_wizard.xml +30 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/document_import_wizard_mixin.py +132 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/document_import_wizard_mixin.xml +44 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/document_status_wizard.xml +58 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/invalidate_number_wizard.py +33 -0
- odoo/addons/l10n_br_fiscal_edi/wizards/invalidate_number_wizard.xml +30 -0
- odoo_addon_l10n_br_fiscal_edi-15.0.1.0.0.2.dist-info/METADATA +141 -0
- odoo_addon_l10n_br_fiscal_edi-15.0.1.0.0.2.dist-info/RECORD +42 -0
- odoo_addon_l10n_br_fiscal_edi-15.0.1.0.0.2.dist-info/WHEEL +5 -0
- odoo_addon_l10n_br_fiscal_edi-15.0.1.0.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,387 @@
|
|
1
|
+
# Copyright (C) 2019 KMEE INFORMATICA LTDA
|
2
|
+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
3
|
+
|
4
|
+
from erpbrasil.base.fiscal.edoc import ChaveEdoc
|
5
|
+
|
6
|
+
from odoo import _, api, fields, models
|
7
|
+
from odoo.exceptions import UserError
|
8
|
+
|
9
|
+
from odoo.addons.l10n_br_fiscal.constants.fiscal import (
|
10
|
+
DOCUMENT_ISSUER_COMPANY,
|
11
|
+
MODELO_FISCAL_CTE,
|
12
|
+
MODELO_FISCAL_NFCE,
|
13
|
+
MODELO_FISCAL_NFE,
|
14
|
+
MODELO_FISCAL_NFSE,
|
15
|
+
SITUACAO_EDOC_A_ENVIAR,
|
16
|
+
SITUACAO_EDOC_AUTORIZADA,
|
17
|
+
SITUACAO_EDOC_CANCELADA,
|
18
|
+
SITUACAO_EDOC_DENEGADA,
|
19
|
+
SITUACAO_EDOC_EM_DIGITACAO,
|
20
|
+
SITUACAO_EDOC_ENVIADA,
|
21
|
+
SITUACAO_EDOC_INUTILIZADA,
|
22
|
+
SITUACAO_EDOC_REJEITADA,
|
23
|
+
SITUACAO_FISCAL_SPED_CONSIDERA_CANCELADO,
|
24
|
+
WORKFLOW_DOCUMENTO_NAO_ELETRONICO,
|
25
|
+
WORKFLOW_EDOC,
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
class DocumentWorkflow(models.AbstractModel):
|
30
|
+
"""
|
31
|
+
This mixin encapsulates the fiscal_state and state_edoc transitions logic.
|
32
|
+
This is legacy code that was made by the KMEE company in version 10
|
33
|
+
and included in the l10n_br_fiscal in version 12. The strange method names
|
34
|
+
with _exec_after_*/_exec_before_* reflect the old Odoo "low-code"
|
35
|
+
"state machine" for invoices that was customized in version 8 by Akretion.
|
36
|
+
So this legacy code can probably be improved a lot...
|
37
|
+
"""
|
38
|
+
|
39
|
+
_name = "l10n_br_fiscal.document.workflow"
|
40
|
+
_description = "Fiscal Document Workflow"
|
41
|
+
|
42
|
+
cancel_reason = fields.Char()
|
43
|
+
|
44
|
+
correction_reason = fields.Char()
|
45
|
+
|
46
|
+
def _direct_draft_send(self):
|
47
|
+
return False
|
48
|
+
|
49
|
+
@api.model
|
50
|
+
def _avaliable_transition(self, old_state, new_state):
|
51
|
+
"""Verifica as transições disponiveis, para não permitir alterações
|
52
|
+
de estado desconhecidas. Para mais detalhes verificar a variável
|
53
|
+
WORKFLOW_EDOC
|
54
|
+
|
55
|
+
(old_state, new_state) in (SITUACAO_EDOC_EM_DIGITACAO,
|
56
|
+
SITUACAO_EDOC_A_ENVIAR)
|
57
|
+
|
58
|
+
:param old_state: estado antigo
|
59
|
+
:param new_state: novo estado
|
60
|
+
:return:
|
61
|
+
"""
|
62
|
+
self.ensure_one()
|
63
|
+
if self.document_electronic:
|
64
|
+
return (old_state, new_state) in WORKFLOW_EDOC
|
65
|
+
else:
|
66
|
+
return (old_state, new_state) in WORKFLOW_DOCUMENTO_NAO_ELETRONICO
|
67
|
+
|
68
|
+
def _exec_before_SITUACAO_EDOC_EM_DIGITACAO(self, old_state, new_state):
|
69
|
+
return True
|
70
|
+
|
71
|
+
def _exec_before_SITUACAO_EDOC_A_ENVIAR(self, old_state, new_state):
|
72
|
+
self._document_date()
|
73
|
+
self._document_number()
|
74
|
+
self._document_comment()
|
75
|
+
self._document_check()
|
76
|
+
self._document_export()
|
77
|
+
return True
|
78
|
+
|
79
|
+
def _exec_before_SITUACAO_EDOC_ENVIADA(self, old_state, new_state):
|
80
|
+
return True
|
81
|
+
|
82
|
+
def _exec_before_SITUACAO_EDOC_REJEITADA(self, old_state, new_state):
|
83
|
+
return True
|
84
|
+
|
85
|
+
def _exec_before_SITUACAO_EDOC_AUTORIZADA(self, old_state, new_state):
|
86
|
+
self._document_date()
|
87
|
+
return True
|
88
|
+
|
89
|
+
def _exec_before_SITUACAO_EDOC_CANCELADA(self, old_state, new_state):
|
90
|
+
return True
|
91
|
+
|
92
|
+
def _exec_before_SITUACAO_EDOC_DENEGADA(self, old_state, new_state):
|
93
|
+
return True
|
94
|
+
|
95
|
+
def _exec_before_SITUACAO_EDOC_INUTILIZADA(self, old_state, new_state):
|
96
|
+
return True
|
97
|
+
|
98
|
+
def _before_change_state(self, old_state, new_state):
|
99
|
+
"""Hook para realizar alterações depois da alteração do estado do doc.
|
100
|
+
|
101
|
+
A variável self.state_edoc já estará com o novo estado neste momento.
|
102
|
+
|
103
|
+
:param old_state:
|
104
|
+
:param new_state:
|
105
|
+
:return:
|
106
|
+
"""
|
107
|
+
self.ensure_one()
|
108
|
+
if new_state == SITUACAO_EDOC_EM_DIGITACAO:
|
109
|
+
return self._exec_before_SITUACAO_EDOC_EM_DIGITACAO(old_state, new_state)
|
110
|
+
elif new_state == SITUACAO_EDOC_A_ENVIAR:
|
111
|
+
return self._exec_before_SITUACAO_EDOC_A_ENVIAR(old_state, new_state)
|
112
|
+
elif new_state == SITUACAO_EDOC_ENVIADA:
|
113
|
+
return self._exec_before_SITUACAO_EDOC_ENVIADA(old_state, new_state)
|
114
|
+
elif new_state == SITUACAO_EDOC_REJEITADA:
|
115
|
+
return self._exec_before_SITUACAO_EDOC_REJEITADA(old_state, new_state)
|
116
|
+
elif new_state == SITUACAO_EDOC_AUTORIZADA:
|
117
|
+
return self._exec_before_SITUACAO_EDOC_AUTORIZADA(old_state, new_state)
|
118
|
+
elif new_state == SITUACAO_EDOC_CANCELADA:
|
119
|
+
return self._exec_before_SITUACAO_EDOC_CANCELADA(old_state, new_state)
|
120
|
+
elif new_state == SITUACAO_EDOC_DENEGADA:
|
121
|
+
return self._exec_before_SITUACAO_EDOC_DENEGADA(old_state, new_state)
|
122
|
+
elif new_state == SITUACAO_EDOC_INUTILIZADA:
|
123
|
+
return self._exec_before_SITUACAO_EDOC_INUTILIZADA(old_state, new_state)
|
124
|
+
|
125
|
+
def _exec_after_SITUACAO_EDOC_EM_DIGITACAO(self, old_state, new_state):
|
126
|
+
self.ensure_one()
|
127
|
+
if self.state_fiscal in SITUACAO_FISCAL_SPED_CONSIDERA_CANCELADO:
|
128
|
+
raise (
|
129
|
+
_(
|
130
|
+
"Não é possível retornar o documento para em \n"
|
131
|
+
"digitação, quando o mesmo esta na situação: \n"
|
132
|
+
"%(old_state)s, %(fiscal_state)s",
|
133
|
+
old_state=old_state,
|
134
|
+
fiscal_state=self.state_fiscal,
|
135
|
+
)
|
136
|
+
)
|
137
|
+
|
138
|
+
def _exec_after_SITUACAO_EDOC_A_ENVIAR(self, old_state, new_state):
|
139
|
+
self.ensure_one()
|
140
|
+
if self._direct_draft_send():
|
141
|
+
self.action_document_send()
|
142
|
+
|
143
|
+
def _exec_after_SITUACAO_EDOC_ENVIADA(self, old_state, new_state):
|
144
|
+
pass
|
145
|
+
|
146
|
+
def _exec_after_SITUACAO_EDOC_REJEITADA(self, old_state, new_state):
|
147
|
+
pass
|
148
|
+
|
149
|
+
def _exec_after_SITUACAO_EDOC_AUTORIZADA(self, old_state, new_state):
|
150
|
+
pass
|
151
|
+
|
152
|
+
def _exec_after_SITUACAO_EDOC_CANCELADA(self, old_state, new_state):
|
153
|
+
pass
|
154
|
+
|
155
|
+
def _exec_after_SITUACAO_EDOC_DENEGADA(self, old_state, new_state):
|
156
|
+
pass
|
157
|
+
|
158
|
+
def _exec_after_SITUACAO_EDOC_INUTILIZADA(self, old_state, new_state):
|
159
|
+
pass
|
160
|
+
|
161
|
+
def _after_change_state(self, old_state, new_state):
|
162
|
+
"""Hook para realizar alterações depois da alteração do estado do doc.
|
163
|
+
|
164
|
+
A variável self.state_edoc já estará com o novo estado neste momento.
|
165
|
+
|
166
|
+
:param old_state:
|
167
|
+
:param new_state:
|
168
|
+
:return:
|
169
|
+
"""
|
170
|
+
self.ensure_one()
|
171
|
+
if new_state == SITUACAO_EDOC_EM_DIGITACAO:
|
172
|
+
self._exec_after_SITUACAO_EDOC_EM_DIGITACAO(old_state, new_state)
|
173
|
+
elif new_state == SITUACAO_EDOC_A_ENVIAR:
|
174
|
+
self._exec_after_SITUACAO_EDOC_A_ENVIAR(old_state, new_state)
|
175
|
+
elif new_state == SITUACAO_EDOC_ENVIADA:
|
176
|
+
self._exec_after_SITUACAO_EDOC_ENVIADA(old_state, new_state)
|
177
|
+
elif new_state == SITUACAO_EDOC_REJEITADA:
|
178
|
+
self._exec_after_SITUACAO_EDOC_REJEITADA(old_state, new_state)
|
179
|
+
elif new_state == SITUACAO_EDOC_AUTORIZADA:
|
180
|
+
self._exec_after_SITUACAO_EDOC_AUTORIZADA(old_state, new_state)
|
181
|
+
elif new_state == SITUACAO_EDOC_CANCELADA:
|
182
|
+
self._exec_after_SITUACAO_EDOC_CANCELADA(old_state, new_state)
|
183
|
+
elif new_state == SITUACAO_EDOC_DENEGADA:
|
184
|
+
self._exec_after_SITUACAO_EDOC_DENEGADA(old_state, new_state)
|
185
|
+
elif new_state == SITUACAO_EDOC_INUTILIZADA:
|
186
|
+
self._exec_after_SITUACAO_EDOC_INUTILIZADA(old_state, new_state)
|
187
|
+
|
188
|
+
self._generates_subsequent_operations()
|
189
|
+
|
190
|
+
def _change_state(self, new_state, force_change=False):
|
191
|
+
"""Método para alterar o estado do documento fiscal, mantendo a
|
192
|
+
integridade do workflow da invoice.
|
193
|
+
|
194
|
+
Tenha muito cuidado ao alterar o workflow da invoice manualmente,
|
195
|
+
prefira alterar o estado do documento fiscal e ele se encarregar de
|
196
|
+
alterar o estado da invoice.
|
197
|
+
|
198
|
+
:param new_state: Novo estado
|
199
|
+
:return: status: Status da conclusão da mudança de estado
|
200
|
+
"""
|
201
|
+
|
202
|
+
status = False
|
203
|
+
for record in self:
|
204
|
+
old_state = record.state_edoc
|
205
|
+
|
206
|
+
if force_change or record._avaliable_transition(old_state, new_state):
|
207
|
+
pass
|
208
|
+
else:
|
209
|
+
raise UserError(
|
210
|
+
_(
|
211
|
+
"Não é possível realizar esta operação,\n"
|
212
|
+
"esta transição não é permitida:\n\n"
|
213
|
+
"De: {old_state}\n\n Para: {new_state}"
|
214
|
+
).format(old_state=old_state, new_state=new_state)
|
215
|
+
)
|
216
|
+
|
217
|
+
if record._before_change_state(old_state, new_state):
|
218
|
+
record.state_edoc = new_state
|
219
|
+
record._after_change_state(old_state, new_state)
|
220
|
+
status = True
|
221
|
+
|
222
|
+
return status
|
223
|
+
|
224
|
+
def _document_date(self):
|
225
|
+
if not self.document_date:
|
226
|
+
self.document_date = self._date_server_format()
|
227
|
+
if not self.date_in_out:
|
228
|
+
self.date_in_out = self._date_server_format()
|
229
|
+
|
230
|
+
def _document_check(self):
|
231
|
+
return True
|
232
|
+
|
233
|
+
def _generate_key(self):
|
234
|
+
for record in self:
|
235
|
+
if record.document_type_id.code in (
|
236
|
+
MODELO_FISCAL_NFE,
|
237
|
+
MODELO_FISCAL_NFCE,
|
238
|
+
MODELO_FISCAL_CTE,
|
239
|
+
):
|
240
|
+
date = fields.Datetime.context_timestamp(record, record.document_date)
|
241
|
+
chave_edoc = ChaveEdoc(
|
242
|
+
ano_mes=date.strftime("%y%m").zfill(4),
|
243
|
+
cnpj_cpf_emitente=record.company_cnpj_cpf,
|
244
|
+
codigo_uf=(
|
245
|
+
record.company_state_id
|
246
|
+
and record.company_state_id.ibge_code
|
247
|
+
or ""
|
248
|
+
),
|
249
|
+
forma_emissao=1, # TODO: Implementar campo no Odoo
|
250
|
+
modelo_documento=record.document_type_id.code or "",
|
251
|
+
numero_documento=record.document_number or "",
|
252
|
+
numero_serie=record.document_serie or "",
|
253
|
+
validar=False,
|
254
|
+
)
|
255
|
+
# TODO: Implementar campos no Odoo
|
256
|
+
# record.key_number = chave_edoc.campos
|
257
|
+
# record.key_formated = ' '.joint(chave_edoc.partes())
|
258
|
+
record.document_key = chave_edoc.chave
|
259
|
+
|
260
|
+
def _document_number(self):
|
261
|
+
self.ensure_one()
|
262
|
+
if self.issuer == DOCUMENT_ISSUER_COMPANY:
|
263
|
+
if self.document_serie_id:
|
264
|
+
self.document_serie = self.document_serie_id.code
|
265
|
+
|
266
|
+
if self.document_type == MODELO_FISCAL_NFSE and not self.rps_number:
|
267
|
+
self.rps_number = self.document_serie_id.next_seq_number()
|
268
|
+
|
269
|
+
if (
|
270
|
+
self.document_type != MODELO_FISCAL_NFSE
|
271
|
+
and not self.document_number
|
272
|
+
):
|
273
|
+
self.document_number = self.document_serie_id.next_seq_number()
|
274
|
+
|
275
|
+
if not self.operation_name:
|
276
|
+
self.operation_name = ", ".join(
|
277
|
+
[
|
278
|
+
line.name
|
279
|
+
for line in self.fiscal_line_ids.mapped("fiscal_operation_id")
|
280
|
+
]
|
281
|
+
)
|
282
|
+
|
283
|
+
if self.document_electronic and not self.document_key:
|
284
|
+
self._generate_key()
|
285
|
+
|
286
|
+
def _document_confirm(self):
|
287
|
+
if self.issuer == DOCUMENT_ISSUER_COMPANY:
|
288
|
+
if not self.comment_ids and self.fiscal_operation_id.comment_ids:
|
289
|
+
self.comment_ids |= self.fiscal_operation_id.comment_ids
|
290
|
+
|
291
|
+
for line in self.fiscal_line_ids:
|
292
|
+
if not line.comment_ids and line.fiscal_operation_line_id.comment_ids:
|
293
|
+
line.comment_ids |= line.fiscal_operation_line_id.comment_ids
|
294
|
+
self._change_state(SITUACAO_EDOC_A_ENVIAR)
|
295
|
+
else:
|
296
|
+
self._change_state(SITUACAO_EDOC_AUTORIZADA)
|
297
|
+
|
298
|
+
def _document_confirm_to_send(self):
|
299
|
+
to_confirm = self.filtered(lambda inv: inv.state_edoc != SITUACAO_EDOC_A_ENVIAR)
|
300
|
+
if to_confirm:
|
301
|
+
to_confirm._document_confirm()
|
302
|
+
|
303
|
+
def _no_eletronic_document_send(self):
|
304
|
+
self._change_state(SITUACAO_EDOC_AUTORIZADA)
|
305
|
+
|
306
|
+
def _document_export(self):
|
307
|
+
pass
|
308
|
+
|
309
|
+
def _action_document_send(self):
|
310
|
+
to_send = self.filtered(
|
311
|
+
lambda d: d.state_edoc
|
312
|
+
in (
|
313
|
+
SITUACAO_EDOC_A_ENVIAR,
|
314
|
+
SITUACAO_EDOC_ENVIADA,
|
315
|
+
SITUACAO_EDOC_REJEITADA,
|
316
|
+
)
|
317
|
+
)
|
318
|
+
if to_send:
|
319
|
+
to_send._document_send()
|
320
|
+
|
321
|
+
def document_back2draft(self):
|
322
|
+
self.xml_error_message = False
|
323
|
+
self.file_report_id = False
|
324
|
+
if self.issuer == DOCUMENT_ISSUER_COMPANY:
|
325
|
+
self._change_state(SITUACAO_EDOC_EM_DIGITACAO)
|
326
|
+
else:
|
327
|
+
self.state_edoc = SITUACAO_EDOC_EM_DIGITACAO
|
328
|
+
|
329
|
+
def _action_document_back2draft(self):
|
330
|
+
self.document_back2draft()
|
331
|
+
|
332
|
+
def _document_cancel(self, justificative):
|
333
|
+
self.ensure_one()
|
334
|
+
self.cancel_reason = justificative
|
335
|
+
if self._change_state(SITUACAO_EDOC_CANCELADA):
|
336
|
+
self.cancel_reason = justificative
|
337
|
+
|
338
|
+
def _action_document_cancel(self):
|
339
|
+
self.ensure_one()
|
340
|
+
if self.issuer == DOCUMENT_ISSUER_COMPANY:
|
341
|
+
if self.state_edoc == SITUACAO_EDOC_AUTORIZADA:
|
342
|
+
result = self.env["ir.actions.act_window"]._for_xml_id(
|
343
|
+
"l10n_br_fiscal_edi.document_cancel_wizard_action"
|
344
|
+
)
|
345
|
+
return result
|
346
|
+
else:
|
347
|
+
self.state_edoc = SITUACAO_EDOC_CANCELADA
|
348
|
+
|
349
|
+
def _action_document_invalidate(self):
|
350
|
+
self.ensure_one()
|
351
|
+
if (
|
352
|
+
self.document_number
|
353
|
+
and self.document_serie
|
354
|
+
and self.state_edoc
|
355
|
+
in (
|
356
|
+
SITUACAO_EDOC_EM_DIGITACAO,
|
357
|
+
SITUACAO_EDOC_REJEITADA,
|
358
|
+
SITUACAO_EDOC_A_ENVIAR,
|
359
|
+
)
|
360
|
+
and self.issuer == DOCUMENT_ISSUER_COMPANY
|
361
|
+
):
|
362
|
+
return self.env["ir.actions.act_window"]._for_xml_id(
|
363
|
+
"l10n_br_fiscal_edi.invalidate_number_wizard_action"
|
364
|
+
)
|
365
|
+
else:
|
366
|
+
raise UserError(_("You cannot invalidate this document"))
|
367
|
+
|
368
|
+
def _document_correction(self, justificative):
|
369
|
+
self.ensure_one()
|
370
|
+
self.correction_reason = justificative
|
371
|
+
|
372
|
+
def _action_document_correction(self):
|
373
|
+
self.ensure_one()
|
374
|
+
if (
|
375
|
+
self.state_edoc in SITUACAO_EDOC_AUTORIZADA
|
376
|
+
and self.issuer == DOCUMENT_ISSUER_COMPANY
|
377
|
+
):
|
378
|
+
return self.env["ir.actions.act_window"]._for_xml_id(
|
379
|
+
"l10n_br_fiscal_edi.document_correction_wizard_action"
|
380
|
+
)
|
381
|
+
else:
|
382
|
+
raise UserError(
|
383
|
+
_(
|
384
|
+
"You cannot create a fiscal correction document if "
|
385
|
+
"this fical document you are not the document issuer"
|
386
|
+
)
|
387
|
+
)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (C) 2009 - TODAY Renato Lima - Akretion
|
2
|
+
# Copyright (C) 2014 KMEE - www.kmee.com.br
|
3
|
+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
4
|
+
|
5
|
+
from odoo import fields, models
|
6
|
+
|
7
|
+
|
8
|
+
class InvalidateNumber(models.Model):
|
9
|
+
_inherit = "l10n_br_fiscal.invalidate.number"
|
10
|
+
|
11
|
+
event_ids = fields.One2many(
|
12
|
+
comodel_name="l10n_br_fiscal.event",
|
13
|
+
inverse_name="invalidate_number_id",
|
14
|
+
string="Events",
|
15
|
+
readonly=True,
|
16
|
+
states={"done": [("readonly", True)]},
|
17
|
+
)
|
18
|
+
|
19
|
+
# Authorization Event Related Fields
|
20
|
+
authorization_event_id = fields.Many2one(
|
21
|
+
comodel_name="l10n_br_fiscal.event",
|
22
|
+
string="Authorization Event",
|
23
|
+
readonly=True,
|
24
|
+
copy=False,
|
25
|
+
)
|
26
|
+
|
27
|
+
authorization_date = fields.Datetime(
|
28
|
+
string="Authorization Date",
|
29
|
+
readonly=True,
|
30
|
+
related="authorization_event_id.protocol_date",
|
31
|
+
)
|
32
|
+
|
33
|
+
authorization_protocol = fields.Char(
|
34
|
+
string="Authorization Protocol",
|
35
|
+
related="authorization_event_id.protocol_number",
|
36
|
+
readonly=True,
|
37
|
+
)
|
38
|
+
|
39
|
+
send_file_id = fields.Many2one(
|
40
|
+
comodel_name="ir.attachment",
|
41
|
+
related="authorization_event_id.file_request_id",
|
42
|
+
string="Send Document File XML",
|
43
|
+
ondelete="restrict",
|
44
|
+
readonly=True,
|
45
|
+
)
|
46
|
+
|
47
|
+
authorization_file_id = fields.Many2one(
|
48
|
+
comodel_name="ir.attachment",
|
49
|
+
related="authorization_event_id.file_response_id",
|
50
|
+
string="Authorization File XML",
|
51
|
+
ondelete="restrict",
|
52
|
+
readonly=True,
|
53
|
+
)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Este módulo estende o módulo `l10n_br_fiscal` e cuida da parte de EDI
|
2
|
+
(Electronic Data Interchange) que é comum entre os vários documentos
|
3
|
+
fiscais no Brasil. Ele introduz os modelos de eventos de transmissão, de
|
4
|
+
correções... Alem disso ele cuida das possíveis transições de estado do
|
5
|
+
documento fiscal em função dos retornos dos webservices (campo
|
6
|
+
`state_edoc`).
|
@@ -0,0 +1,6 @@
|
|
1
|
+
O código deste módulo foi feito antes dos repos `OCA/edi` e
|
2
|
+
`OCA/edi-framework`. O código do `document_workflow.py` por exemplo foi
|
3
|
+
uma espécie de tradução em código do "workflow de state machine" que
|
4
|
+
tinha sido customizado para a NFe na versão 8.0 mas que teve que ser
|
5
|
+
re-escrito quando o engine de workflow foi removido na versão 10.0.
|
6
|
+
Nisso o código deste módulo tem bastante possibilidades de melhorias...
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Use os botões na barra de header do documento fiscal para alterar o
|
2
|
+
estado do documento fiscal, para abrir os wizards e para interagir com a
|
3
|
+
fazenda... Quando o módulo `l10n_br_account` ou alguns módulos de
|
4
|
+
documentos fiscais específicos como `l10n_br_nfe` ou `l10n_br_nfse` são
|
5
|
+
instalados, alguns métodos de transição de estado do módulo
|
6
|
+
`l10n_br_fiscal_edi` são chamados automaticamente, por exemplo ao
|
7
|
+
confirmar ou cancelar uma nota.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
2
|
+
"l10n_br_fiscal_event_user","Fiscal Document Event for User","model_l10n_br_fiscal_event","l10n_br_fiscal.group_user",1,1,1,0
|
3
|
+
"l10n_br_fiscal_invalidate_number_user","user_l10n_br_fiscal_invalidate_number","model_l10n_br_fiscal_invalidate_number","l10n_br_fiscal.group_user",1,0,0,0
|
4
|
+
"l10n_br_fiscal_invalidate_number_manager","manager_l10n_br_fiscal_invalidate_number","model_l10n_br_fiscal_invalidate_number","l10n_br_fiscal.group_manager",1,1,1,1
|
5
|
+
"l10n_br_fiscal_document_cancel_wizard_user",l10n_br_fiscal_document_cancel_wizard,model_l10n_br_fiscal_document_cancel_wizard,base.group_user,1,1,1,1
|
6
|
+
"l10n_br_fiscal_document_correction_wizard_user",l10n_br_fiscal_document_correction_wizard,model_l10n_br_fiscal_document_correction_wizard,base.group_user,1,1,1,1
|
7
|
+
"l10n_br_fiscal_document_import_wizard_mixin_user",l10n_br_fiscal_document_import_wizard_mixin_user,model_l10n_br_fiscal_document_import_wizard_mixin,base.group_user,1,1,1,1
|
Binary file
|