10
10
from odoo .exceptions import ValidationError
11
11
12
12
from ..constants .fiscal import (
13
+ DOCUMENT_ISSUER ,
13
14
DOCUMENT_ISSUER_COMPANY ,
14
15
DOCUMENT_ISSUER_DICT ,
15
16
DOCUMENT_ISSUER_PARTNER ,
20
21
MODELO_FISCAL_NFCE ,
21
22
MODELO_FISCAL_NFE ,
22
23
MODELO_FISCAL_NFSE ,
24
+ SITUACAO_EDOC ,
23
25
SITUACAO_EDOC_AUTORIZADA ,
24
26
SITUACAO_EDOC_CANCELADA ,
25
27
SITUACAO_EDOC_DENEGADA ,
28
+ SITUACAO_EDOC_EM_DIGITACAO ,
26
29
SITUACAO_EDOC_INUTILIZADA ,
30
+ SITUACAO_FISCAL ,
27
31
)
28
32
29
33
@@ -49,7 +53,6 @@ class Document(models.Model):
49
53
_name = "l10n_br_fiscal.document"
50
54
_inherit = [
51
55
"l10n_br_fiscal.document.mixin.fields" ,
52
- "l10n_br_fiscal.document.electronic" ,
53
56
"l10n_br_fiscal.document.move.mixin" ,
54
57
"mail.thread" ,
55
58
]
@@ -62,6 +65,25 @@ class Document(models.Model):
62
65
index = True ,
63
66
)
64
67
68
+ state_edoc = fields .Selection (
69
+ selection = SITUACAO_EDOC ,
70
+ string = "Situação e-doc" ,
71
+ default = SITUACAO_EDOC_EM_DIGITACAO ,
72
+ copy = False ,
73
+ required = True ,
74
+ readonly = True ,
75
+ # tracking=True,
76
+ index = True ,
77
+ )
78
+
79
+ state_fiscal = fields .Selection (
80
+ selection = SITUACAO_FISCAL ,
81
+ string = "Situação Fiscal" ,
82
+ copy = False ,
83
+ # tracking=True,
84
+ index = True ,
85
+ )
86
+
65
87
fiscal_operation_id = fields .Many2one (
66
88
domain = "[('state', '=', 'approved'), "
67
89
"'|', ('fiscal_operation_type', '=', fiscal_operation_type),"
@@ -140,23 +162,6 @@ class Document(models.Model):
140
162
default = EDOC_PURPOSE_NORMAL ,
141
163
)
142
164
143
- event_ids = fields .One2many (
144
- comodel_name = "l10n_br_fiscal.event" ,
145
- inverse_name = "document_id" ,
146
- string = "Events" ,
147
- copy = False ,
148
- readonly = True ,
149
- )
150
-
151
- correction_event_ids = fields .One2many (
152
- comodel_name = "l10n_br_fiscal.event" ,
153
- inverse_name = "document_id" ,
154
- domain = [("type" , "=" , "14" )],
155
- string = "Correction Events" ,
156
- copy = False ,
157
- readonly = True ,
158
- )
159
-
160
165
document_type = fields .Char (
161
166
string = "Document Type Code" ,
162
167
related = "document_type_id.code" ,
@@ -171,10 +176,16 @@ class Document(models.Model):
171
176
copy = False ,
172
177
)
173
178
174
- # Você não vai poder fazer isso em modelos que já tem state
175
- # TODO Porque não usar o campo state do fiscal.document???
179
+ # this related "state" field is required for the status bar widget
180
+ # while state_edoc avoids colliding with the state field
181
+ # of objects where the fiscal mixin might be injected.
176
182
state = fields .Selection (related = "state_edoc" , string = "State" )
177
183
184
+ issuer = fields .Selection (
185
+ selection = DOCUMENT_ISSUER ,
186
+ default = DOCUMENT_ISSUER_COMPANY ,
187
+ )
188
+
178
189
document_subsequent_ids = fields .One2many (
179
190
comodel_name = "l10n_br_fiscal.subsequent.document" ,
180
191
inverse_name = "source_document_id" ,
@@ -404,6 +415,37 @@ def action_create_return(self):
404
415
405
416
return action
406
417
418
+ # the following actions are meant to be implemented in other modules such as
419
+ # l10n_br_fiscal_edi. They are defined here so they can be overriden in modules
420
+ # that don't depend on l10n_br_fiscal_edi (such as l10n_br_account).
421
+ def view_pdf (self ):
422
+ pass
423
+
424
+ def view_xml (self ):
425
+ pass
426
+
427
+ def action_document_confirm (self ):
428
+ pass
429
+
430
+ def action_document_send (self ):
431
+ pass
432
+
433
+ def action_document_back2draft (self ):
434
+ pass
435
+
436
+ def action_document_cancel (self ):
437
+ pass
438
+
439
+ def action_document_invalidate (self ):
440
+ pass
441
+
442
+ def action_document_correction (self ):
443
+ pass
444
+
445
+ def exec_after_SITUACAO_EDOC_DENEGADA (self , old_state , new_state ):
446
+ # see https://github.com/OCA/l10n-brazil/pull/3272
447
+ pass
448
+
407
449
def _get_email_template (self , state ):
408
450
self .ensure_one ()
409
451
return self .document_type_id .document_email_ids .search (
0 commit comments