odoo-addon-l10n-br-fiscal 16.0.1.18.2.3__py3-none-any.whl → 16.0.2.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.

Potentially problematic release.


This version of odoo-addon-l10n-br-fiscal might be problematic. Click here for more details.

Files changed (41) hide show
  1. odoo/addons/l10n_br_fiscal/README.rst +1 -1
  2. odoo/addons/l10n_br_fiscal/__manifest__.py +2 -12
  3. odoo/addons/l10n_br_fiscal/i18n/l10n_br_fiscal.pot +0 -820
  4. odoo/addons/l10n_br_fiscal/migrations/16.0.2.0.0/pre-migration.py +25 -0
  5. odoo/addons/l10n_br_fiscal/models/__init__.py +0 -3
  6. odoo/addons/l10n_br_fiscal/models/document.py +62 -20
  7. odoo/addons/l10n_br_fiscal/models/invalidate_number.py +0 -44
  8. odoo/addons/l10n_br_fiscal/security/ir.model.access.csv +0 -5
  9. odoo/addons/l10n_br_fiscal/static/description/index.html +1 -1
  10. odoo/addons/l10n_br_fiscal/tests/__init__.py +0 -1
  11. odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_generic.py +0 -48
  12. odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_nfse.py +0 -2
  13. odoo/addons/l10n_br_fiscal/tests/test_subsequent_operation.py +2 -1
  14. odoo/addons/l10n_br_fiscal/tests/test_tax_benefit.py +0 -21
  15. odoo/addons/l10n_br_fiscal/views/document_view.xml +3 -69
  16. odoo/addons/l10n_br_fiscal/views/invalidate_number_view.xml +2 -7
  17. odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_action.xml +0 -34
  18. odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_menu.xml +0 -19
  19. odoo/addons/l10n_br_fiscal/wizards/__init__.py +0 -6
  20. odoo/addons/l10n_br_fiscal/wizards/base_wizard_mixin.py +0 -5
  21. odoo/addons/l10n_br_fiscal/wizards/document_status_wizard.py +2 -0
  22. {odoo_addon_l10n_br_fiscal-16.0.1.18.2.3.dist-info → odoo_addon_l10n_br_fiscal-16.0.2.0.0.2.dist-info}/METADATA +3 -3
  23. {odoo_addon_l10n_br_fiscal-16.0.1.18.2.3.dist-info → odoo_addon_l10n_br_fiscal-16.0.2.0.0.2.dist-info}/RECORD +25 -40
  24. odoo/addons/l10n_br_fiscal/models/document_eletronic.py +0 -233
  25. odoo/addons/l10n_br_fiscal/models/document_event.py +0 -392
  26. odoo/addons/l10n_br_fiscal/models/document_workflow.py +0 -402
  27. odoo/addons/l10n_br_fiscal/tests/test_workflow.py +0 -118
  28. odoo/addons/l10n_br_fiscal/views/document_event_report.xml +0 -15
  29. odoo/addons/l10n_br_fiscal/views/document_event_template.xml +0 -114
  30. odoo/addons/l10n_br_fiscal/views/document_event_view.xml +0 -68
  31. odoo/addons/l10n_br_fiscal/wizards/document_cancel_wizard.py +0 -20
  32. odoo/addons/l10n_br_fiscal/wizards/document_cancel_wizard.xml +0 -30
  33. odoo/addons/l10n_br_fiscal/wizards/document_correction_wizard.py +0 -17
  34. odoo/addons/l10n_br_fiscal/wizards/document_correction_wizard.xml +0 -30
  35. odoo/addons/l10n_br_fiscal/wizards/document_import_wizard_mixin.py +0 -132
  36. odoo/addons/l10n_br_fiscal/wizards/document_import_wizard_mixin.xml +0 -44
  37. odoo/addons/l10n_br_fiscal/wizards/document_status_wizard.xml +0 -58
  38. odoo/addons/l10n_br_fiscal/wizards/invalidate_number_wizard.py +0 -29
  39. odoo/addons/l10n_br_fiscal/wizards/invalidate_number_wizard.xml +0 -30
  40. {odoo_addon_l10n_br_fiscal-16.0.1.18.2.3.dist-info → odoo_addon_l10n_br_fiscal-16.0.2.0.0.2.dist-info}/WHEEL +0 -0
  41. {odoo_addon_l10n_br_fiscal-16.0.1.18.2.3.dist-info → odoo_addon_l10n_br_fiscal-16.0.2.0.0.2.dist-info}/top_level.txt +0 -0
@@ -1,392 +0,0 @@
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
- import base64
6
- import logging
7
- import os
8
-
9
- from odoo import _, api, fields, models
10
- from odoo.exceptions import UserError
11
-
12
- from ..constants.fiscal import EVENT_ENVIRONMENT
13
- from ..tools import build_edoc_path
14
-
15
- _logger = logging.getLogger(__name__)
16
-
17
- FILE_SUFIX_EVENT = {
18
- "0": "env",
19
- "1": "con-rec",
20
- "2": "can",
21
- "3": "inu",
22
- "4": "con-edoc",
23
- "5": "con-status",
24
- "6": "con-cad",
25
- "7": "dpec-rec",
26
- "8": "dpec-con",
27
- "9": "rec-eve",
28
- "10": "dow",
29
- "11": "con-dest",
30
- "12": "dist-dfe",
31
- "13": "man",
32
- "14": "cce",
33
- }
34
-
35
-
36
- class Event(models.Model):
37
- _name = "l10n_br_fiscal.event"
38
- _description = "Fiscal Event"
39
-
40
- @api.depends("document_id.name", "invalidate_number_id.name")
41
- def _compute_display_name(self):
42
- for record in self:
43
- if record.document_id:
44
- names = [
45
- _("Fiscal Document"),
46
- record.document_id.name,
47
- ]
48
- record.display_name = " / ".join(filter(None, names))
49
- elif record.invalidate_number_id:
50
- names = [
51
- _("Invalidate Number"),
52
- record.invalidate_number_id.name,
53
- ]
54
- record.display_name = " / ".join(filter(None, names))
55
- else:
56
- record.display_name = ""
57
-
58
- create_date = fields.Datetime(
59
- readonly=True,
60
- index=True,
61
- default=fields.Datetime.now,
62
- )
63
-
64
- write_date = fields.Datetime(
65
- readonly=True,
66
- index=True,
67
- )
68
-
69
- type = fields.Selection(
70
- selection=[
71
- ("-1", "Exception"),
72
- ("0", "Autorização de Uso"),
73
- ("1", "Consulta Recibo"),
74
- ("2", "Cancelamento"),
75
- ("3", "Inutilização"),
76
- ("4", "Consulta NFE"),
77
- ("5", "Consulta Situação"),
78
- ("6", "Consulta Cadastro"),
79
- ("7", "DPEC Recepção"),
80
- ("8", "DPEC Consulta"),
81
- ("9", "Recepção Evento"),
82
- ("10", "Download"),
83
- ("11", "Consulta Destinadas"),
84
- ("12", "Distribuição DFe"),
85
- ("13", "Manifestação"),
86
- ("14", "Carta de Correção"),
87
- ],
88
- string="Service",
89
- )
90
-
91
- origin = fields.Char(
92
- string="Source Document",
93
- readonly=True,
94
- help="Document reference that generated this event.",
95
- )
96
-
97
- document_id = fields.Many2one(
98
- comodel_name="l10n_br_fiscal.document",
99
- string="Fiscal Document",
100
- index=True,
101
- )
102
-
103
- document_type_id = fields.Many2one(
104
- comodel_name="l10n_br_fiscal.document.type",
105
- string="Fiscal Document Type",
106
- index=True,
107
- required=True,
108
- )
109
-
110
- document_serie_id = fields.Many2one(
111
- comodel_name="l10n_br_fiscal.document.serie",
112
- required=True,
113
- )
114
-
115
- document_number = fields.Char(
116
- required=True,
117
- )
118
-
119
- partner_id = fields.Many2one(
120
- comodel_name="res.partner",
121
- string="Partner",
122
- index=True,
123
- )
124
-
125
- invalidate_number_id = fields.Many2one(
126
- comodel_name="l10n_br_fiscal.invalidate.number",
127
- string="Invalidate Number",
128
- index=True,
129
- )
130
-
131
- company_id = fields.Many2one(
132
- comodel_name="res.company",
133
- string="Company",
134
- index=True,
135
- required=True,
136
- )
137
-
138
- sequence = fields.Char(
139
- help="Fiscal Document Event Sequence",
140
- )
141
-
142
- justification = fields.Char()
143
-
144
- display_name = fields.Char(
145
- string="name",
146
- compute="_compute_display_name",
147
- store=True,
148
- )
149
-
150
- file_request_id = fields.Many2one(
151
- comodel_name="ir.attachment",
152
- string="XML",
153
- copy=False,
154
- readonly=True,
155
- )
156
-
157
- file_response_id = fields.Many2one(
158
- comodel_name="ir.attachment",
159
- string="XML Response",
160
- copy=False,
161
- readonly=True,
162
- )
163
-
164
- file_path = fields.Char(
165
- readonly=True,
166
- )
167
-
168
- status_code = fields.Char(
169
- readonly=True,
170
- )
171
-
172
- response = fields.Char(
173
- string="Response Message",
174
- readonly=True,
175
- )
176
-
177
- message = fields.Char(
178
- readonly=True,
179
- )
180
-
181
- protocol_date = fields.Datetime(
182
- readonly=True,
183
- index=True,
184
- )
185
-
186
- protocol_number = fields.Char()
187
-
188
- lot_receipt_number = fields.Char(
189
- help=(
190
- "In asynchronous processing, a lot receipt number is generated, "
191
- "which is used for later consultation."
192
- ),
193
- )
194
-
195
- state = fields.Selection(
196
- selection=[
197
- ("draft", _("Draft")),
198
- ("send", _("Sending")),
199
- ("wait", _("Waiting Response")),
200
- ("done", _("Response received")),
201
- ],
202
- string="Status",
203
- readonly=True,
204
- index=True,
205
- default="draft",
206
- )
207
-
208
- environment = fields.Selection(
209
- selection=EVENT_ENVIRONMENT,
210
- )
211
-
212
- @api.constrains("justification")
213
- def _check_justification(self):
214
- if len(self.justification) < 15:
215
- raise UserError(_("Justification must be at least 15 characters."))
216
- return True
217
-
218
- def _save_event_2disk(self, arquivo, file_name):
219
- self.ensure_one()
220
- tipo_documento = self.document_type_id.prefix
221
- serie = self.document_serie_id.code
222
- numero = self.document_number
223
-
224
- if self.document_id:
225
- ano = self.document_id.document_date.strftime("%Y")
226
- mes = self.document_id.document_date.strftime("%m")
227
- elif self.invalidate_number_id:
228
- ano = self.invalidate_number_id.date.strftime("%Y")
229
- mes = self.invalidate_number_id.date.strftime("%m")
230
-
231
- save_dir = build_edoc_path(
232
- ambiente=self.environment,
233
- company_id=self.company_id,
234
- tipo_documento=tipo_documento,
235
- ano=ano,
236
- mes=mes,
237
- serie=serie,
238
- numero=numero,
239
- )
240
- file_path = os.path.join(save_dir, file_name)
241
- try:
242
- if not os.path.exists(save_dir):
243
- os.makedirs(save_dir)
244
- f = open(file_path, "w")
245
- except OSError as e:
246
- raise UserError(
247
- _("Erro!"),
248
- _(
249
- """Não foi possível salvar o arquivo
250
- em disco, verifique as permissões de escrita
251
- e o caminho da pasta"""
252
- ),
253
- ) from e
254
- else:
255
- f.write(arquivo)
256
- f.close()
257
- return save_dir
258
-
259
- def _compute_file_name(self):
260
- self.ensure_one()
261
- if (
262
- self.document_id
263
- and self.document_id.document_key
264
- and self.document_id.document_electronic
265
- and self.document_id.document_type_id
266
- and self.document_id.document_type_id.prefix
267
- ):
268
- file_name = (
269
- self.document_id.document_type_id.prefix + self.document_id.document_key
270
- )
271
- else:
272
- file_name = self.document_number
273
- return file_name
274
-
275
- def _save_event_file(
276
- self, file, file_extension, authorization=False, rejected=False
277
- ):
278
- self.ensure_one()
279
- file_name = self._compute_file_name()
280
-
281
- if authorization:
282
- file_name += "-proc"
283
- if rejected:
284
- file_name += "-rej"
285
-
286
- if self.type:
287
- file_name += "-" + FILE_SUFIX_EVENT[self.type]
288
-
289
- if self.sequence:
290
- file_name += "-" + str(self.sequence)
291
- if file_extension:
292
- file_name += "." + file_extension
293
-
294
- if self.company_id.document_save_disk:
295
- file_path = self._save_event_2disk(file, file_name)
296
- self.file_path = file_path
297
-
298
- attachment_id = self.env["ir.attachment"].create(
299
- {
300
- "name": file_name,
301
- "res_model": self._name,
302
- "res_id": self.id,
303
- "datas": base64.b64encode(file.encode("utf-8")),
304
- "mimetype": "application/" + file_extension,
305
- "type": "binary",
306
- }
307
- )
308
-
309
- if authorization:
310
- # Não deletamos um aquivo de autorização já
311
- # Existente por segurança
312
- self.file_response_id = False
313
- self.file_response_id = attachment_id
314
- else:
315
- self.file_request_id.unlink()
316
- self.file_request_id = attachment_id
317
- return attachment_id
318
-
319
- def set_done(
320
- self, status_code, response, protocol_date, protocol_number, file_response_xml
321
- ):
322
- if file_response_xml:
323
- self._save_event_file(file_response_xml, "xml", authorization=True)
324
- self.write(
325
- {
326
- "state": "done",
327
- "status_code": status_code,
328
- "response": response,
329
- "protocol_date": protocol_date,
330
- "protocol_number": protocol_number,
331
- }
332
- )
333
-
334
- def create_event_save_xml(
335
- self,
336
- company_id,
337
- environment,
338
- event_type,
339
- xml_file,
340
- document_id=False,
341
- invalidate_number_id=False,
342
- sequence=False,
343
- justification=False,
344
- ):
345
- vals = {
346
- "company_id": company_id.id,
347
- "environment": environment,
348
- "type": event_type,
349
- }
350
- if sequence:
351
- vals["sequence"] = sequence
352
- if document_id:
353
- #
354
- # Aplicado para envio, cancelamento, carta de correcao
355
- # e outras operações em que o documento esta presente.
356
- #
357
- vals["document_id"] = document_id.id
358
- vals["document_type_id"] = document_id.document_type_id.id
359
- vals["document_serie_id"] = document_id.document_serie_id.id
360
-
361
- if document_id.rps_number:
362
- vals["document_number"] = document_id.rps_number
363
- if document_id.document_number:
364
- vals["document_number"] += "-" + document_id.document_number
365
- else:
366
- vals["document_number"] = document_id.document_number
367
-
368
- if invalidate_number_id:
369
- #
370
- # Aplicado para inutilização
371
- #
372
- vals["invalidate_number_id"] = invalidate_number_id.id
373
- vals["document_type_id"] = invalidate_number_id.document_type_id.id
374
- vals["document_serie_id"] = invalidate_number_id.document_serie_id.id
375
- if invalidate_number_id.number_end != invalidate_number_id.number_start:
376
- vals["document_number"] = (
377
- str(invalidate_number_id.number_start)
378
- + "-"
379
- + str(invalidate_number_id.number_end)
380
- )
381
- else:
382
- vals["document_number"] = invalidate_number_id.number_start
383
- if justification:
384
- vals["justification"] = justification
385
- event_id = self.create(vals)
386
- event_id._save_event_file(xml_file, "xml")
387
- return event_id
388
-
389
- def print_document_event(self):
390
- return self.env.ref(
391
- "l10n_br_fiscal.action_report_document_event"
392
- ).report_action(self)