odoo-addon-l10n-br-fiscal 16.0.1.18.2.3__py3-none-any.whl → 16.0.2.1.0__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 (53) 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 +8 -828
  4. odoo/addons/l10n_br_fiscal/i18n/pt_BR.po +304 -850
  5. odoo/addons/l10n_br_fiscal/migrations/16.0.2.0.0/pre-migration.py +25 -0
  6. odoo/addons/l10n_br_fiscal/models/__init__.py +0 -12
  7. odoo/addons/l10n_br_fiscal/models/document.py +62 -20
  8. odoo/addons/l10n_br_fiscal/models/invalidate_number.py +0 -44
  9. odoo/addons/l10n_br_fiscal/models/ncm.py +27 -0
  10. odoo/addons/l10n_br_fiscal/models/tax_definition.py +189 -1
  11. odoo/addons/l10n_br_fiscal/security/ir.model.access.csv +0 -5
  12. odoo/addons/l10n_br_fiscal/static/description/index.html +1 -1
  13. odoo/addons/l10n_br_fiscal/tests/__init__.py +0 -1
  14. odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_generic.py +0 -48
  15. odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_nfse.py +0 -2
  16. odoo/addons/l10n_br_fiscal/tests/test_subsequent_operation.py +2 -1
  17. odoo/addons/l10n_br_fiscal/tests/test_tax_benefit.py +0 -21
  18. odoo/addons/l10n_br_fiscal/views/document_view.xml +3 -69
  19. odoo/addons/l10n_br_fiscal/views/invalidate_number_view.xml +2 -7
  20. odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_action.xml +0 -34
  21. odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_menu.xml +0 -19
  22. odoo/addons/l10n_br_fiscal/wizards/__init__.py +0 -6
  23. odoo/addons/l10n_br_fiscal/wizards/base_wizard_mixin.py +0 -5
  24. odoo/addons/l10n_br_fiscal/wizards/document_status_wizard.py +2 -0
  25. {odoo_addon_l10n_br_fiscal-16.0.1.18.2.3.dist-info → odoo_addon_l10n_br_fiscal-16.0.2.1.0.dist-info}/METADATA +3 -3
  26. {odoo_addon_l10n_br_fiscal-16.0.1.18.2.3.dist-info → odoo_addon_l10n_br_fiscal-16.0.2.1.0.dist-info}/RECORD +28 -52
  27. odoo/addons/l10n_br_fiscal/models/document_eletronic.py +0 -233
  28. odoo/addons/l10n_br_fiscal/models/document_event.py +0 -392
  29. odoo/addons/l10n_br_fiscal/models/document_workflow.py +0 -402
  30. odoo/addons/l10n_br_fiscal/models/ncm_cest.py +0 -18
  31. odoo/addons/l10n_br_fiscal/models/ncm_nbm.py +0 -18
  32. odoo/addons/l10n_br_fiscal/models/ncm_tax_pis_cofins.py +0 -18
  33. odoo/addons/l10n_br_fiscal/models/tax_definition_benefit.py +0 -119
  34. odoo/addons/l10n_br_fiscal/models/tax_definition_cfop.py +0 -36
  35. odoo/addons/l10n_br_fiscal/models/tax_definition_company.py +0 -29
  36. odoo/addons/l10n_br_fiscal/models/tax_definition_icms.py +0 -36
  37. odoo/addons/l10n_br_fiscal/models/tax_definition_operation_line.py +0 -37
  38. odoo/addons/l10n_br_fiscal/models/tax_definition_partner_profile.py +0 -33
  39. odoo/addons/l10n_br_fiscal/tests/test_workflow.py +0 -118
  40. odoo/addons/l10n_br_fiscal/views/document_event_report.xml +0 -15
  41. odoo/addons/l10n_br_fiscal/views/document_event_template.xml +0 -114
  42. odoo/addons/l10n_br_fiscal/views/document_event_view.xml +0 -68
  43. odoo/addons/l10n_br_fiscal/wizards/document_cancel_wizard.py +0 -20
  44. odoo/addons/l10n_br_fiscal/wizards/document_cancel_wizard.xml +0 -30
  45. odoo/addons/l10n_br_fiscal/wizards/document_correction_wizard.py +0 -17
  46. odoo/addons/l10n_br_fiscal/wizards/document_correction_wizard.xml +0 -30
  47. odoo/addons/l10n_br_fiscal/wizards/document_import_wizard_mixin.py +0 -132
  48. odoo/addons/l10n_br_fiscal/wizards/document_import_wizard_mixin.xml +0 -44
  49. odoo/addons/l10n_br_fiscal/wizards/document_status_wizard.xml +0 -58
  50. odoo/addons/l10n_br_fiscal/wizards/invalidate_number_wizard.py +0 -29
  51. odoo/addons/l10n_br_fiscal/wizards/invalidate_number_wizard.xml +0 -30
  52. {odoo_addon_l10n_br_fiscal-16.0.1.18.2.3.dist-info → odoo_addon_l10n_br_fiscal-16.0.2.1.0.dist-info}/WHEEL +0 -0
  53. {odoo_addon_l10n_br_fiscal-16.0.1.18.2.3.dist-info → odoo_addon_l10n_br_fiscal-16.0.2.1.0.dist-info}/top_level.txt +0 -0
@@ -1,402 +0,0 @@
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 ..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,
16
- SITUACAO_EDOC_A_ENVIAR,
17
- SITUACAO_EDOC_AUTORIZADA,
18
- SITUACAO_EDOC_CANCELADA,
19
- SITUACAO_EDOC_DENEGADA,
20
- SITUACAO_EDOC_EM_DIGITACAO,
21
- SITUACAO_EDOC_ENVIADA,
22
- SITUACAO_EDOC_INUTILIZADA,
23
- SITUACAO_EDOC_REJEITADA,
24
- SITUACAO_FISCAL,
25
- SITUACAO_FISCAL_SPED_CONSIDERA_CANCELADO,
26
- WORKFLOW_DOCUMENTO_NAO_ELETRONICO,
27
- WORKFLOW_EDOC,
28
- )
29
-
30
-
31
- class DocumentWorkflow(models.AbstractModel):
32
- _name = "l10n_br_fiscal.document.workflow"
33
- _description = "Fiscal Document Workflow"
34
-
35
- state_edoc = fields.Selection(
36
- selection=SITUACAO_EDOC,
37
- string="Situação e-doc",
38
- default=SITUACAO_EDOC_EM_DIGITACAO,
39
- copy=False,
40
- required=True,
41
- readonly=True,
42
- # tracking=True,
43
- index=True,
44
- )
45
-
46
- state_fiscal = fields.Selection(
47
- selection=SITUACAO_FISCAL,
48
- string="Situação Fiscal",
49
- copy=False,
50
- # tracking=True,
51
- index=True,
52
- )
53
-
54
- cancel_reason = fields.Char()
55
-
56
- correction_reason = fields.Char()
57
-
58
- def _direct_draft_send(self):
59
- return False
60
-
61
- @api.model
62
- def _avaliable_transition(self, old_state, new_state):
63
- """Verifica as transições disponiveis, para não permitir alterações
64
- de estado desconhecidas. Para mais detalhes verificar a variável
65
- WORKFLOW_EDOC
66
-
67
- (old_state, new_state) in (SITUACAO_EDOC_EM_DIGITACAO,
68
- SITUACAO_EDOC_A_ENVIAR)
69
-
70
- :param old_state: estado antigo
71
- :param new_state: novo estado
72
- :return:
73
- """
74
- self.ensure_one()
75
- if self.document_electronic:
76
- return (old_state, new_state) in WORKFLOW_EDOC
77
- else:
78
- return (old_state, new_state) in WORKFLOW_DOCUMENTO_NAO_ELETRONICO
79
-
80
- def _exec_before_SITUACAO_EDOC_EM_DIGITACAO(self, old_state, new_state):
81
- return True
82
-
83
- def _exec_before_SITUACAO_EDOC_A_ENVIAR(self, old_state, new_state):
84
- self._document_date()
85
- self._document_number()
86
- self._document_comment()
87
- self._document_check()
88
- self._document_export()
89
- return True
90
-
91
- def _exec_before_SITUACAO_EDOC_ENVIADA(self, old_state, new_state):
92
- return True
93
-
94
- def _exec_before_SITUACAO_EDOC_REJEITADA(self, old_state, new_state):
95
- return True
96
-
97
- def _exec_before_SITUACAO_EDOC_AUTORIZADA(self, old_state, new_state):
98
- self._document_date()
99
- return True
100
-
101
- def _exec_before_SITUACAO_EDOC_CANCELADA(self, old_state, new_state):
102
- return True
103
-
104
- def _exec_before_SITUACAO_EDOC_DENEGADA(self, old_state, new_state):
105
- return True
106
-
107
- def _exec_before_SITUACAO_EDOC_INUTILIZADA(self, old_state, new_state):
108
- return True
109
-
110
- def _before_change_state(self, old_state, new_state):
111
- """Hook para realizar alterações depois da alteração do estado do doc.
112
-
113
- A variável self.state_edoc já estará com o novo estado neste momento.
114
-
115
- :param old_state:
116
- :param new_state:
117
- :return:
118
- """
119
- self.ensure_one()
120
- if new_state == SITUACAO_EDOC_EM_DIGITACAO:
121
- return self._exec_before_SITUACAO_EDOC_EM_DIGITACAO(old_state, new_state)
122
- elif new_state == SITUACAO_EDOC_A_ENVIAR:
123
- return self._exec_before_SITUACAO_EDOC_A_ENVIAR(old_state, new_state)
124
- elif new_state == SITUACAO_EDOC_ENVIADA:
125
- return self._exec_before_SITUACAO_EDOC_ENVIADA(old_state, new_state)
126
- elif new_state == SITUACAO_EDOC_REJEITADA:
127
- return self._exec_before_SITUACAO_EDOC_REJEITADA(old_state, new_state)
128
- elif new_state == SITUACAO_EDOC_AUTORIZADA:
129
- return self._exec_before_SITUACAO_EDOC_AUTORIZADA(old_state, new_state)
130
- elif new_state == SITUACAO_EDOC_CANCELADA:
131
- return self._exec_before_SITUACAO_EDOC_CANCELADA(old_state, new_state)
132
- elif new_state == SITUACAO_EDOC_DENEGADA:
133
- return self._exec_before_SITUACAO_EDOC_DENEGADA(old_state, new_state)
134
- elif new_state == SITUACAO_EDOC_INUTILIZADA:
135
- return self._exec_before_SITUACAO_EDOC_INUTILIZADA(old_state, new_state)
136
-
137
- def _exec_after_SITUACAO_EDOC_EM_DIGITACAO(self, old_state, new_state):
138
- self.ensure_one()
139
- if self.state_fiscal in SITUACAO_FISCAL_SPED_CONSIDERA_CANCELADO:
140
- raise (
141
- _(
142
- "Não é possível retornar o documento para em \n"
143
- "digitação, quando o mesmo esta na situação: \n"
144
- "%(old_state)s, %(fiscal_state)s",
145
- old_state=old_state,
146
- fiscal_state=self.state_fiscal,
147
- )
148
- )
149
-
150
- def _exec_after_SITUACAO_EDOC_A_ENVIAR(self, old_state, new_state):
151
- self.ensure_one()
152
- if self._direct_draft_send():
153
- self.action_document_send()
154
-
155
- def _exec_after_SITUACAO_EDOC_ENVIADA(self, old_state, new_state):
156
- pass
157
-
158
- def _exec_after_SITUACAO_EDOC_REJEITADA(self, old_state, new_state):
159
- pass
160
-
161
- def _exec_after_SITUACAO_EDOC_AUTORIZADA(self, old_state, new_state):
162
- pass
163
-
164
- def _exec_after_SITUACAO_EDOC_CANCELADA(self, old_state, new_state):
165
- pass
166
-
167
- def _exec_after_SITUACAO_EDOC_DENEGADA(self, old_state, new_state):
168
- pass
169
-
170
- def _exec_after_SITUACAO_EDOC_INUTILIZADA(self, old_state, new_state):
171
- pass
172
-
173
- def _after_change_state(self, old_state, new_state):
174
- """Hook para realizar alterações depois da alteração do estado do doc.
175
-
176
- A variável self.state_edoc já estará com o novo estado neste momento.
177
-
178
- :param old_state:
179
- :param new_state:
180
- :return:
181
- """
182
- self.ensure_one()
183
- if new_state == SITUACAO_EDOC_EM_DIGITACAO:
184
- self._exec_after_SITUACAO_EDOC_EM_DIGITACAO(old_state, new_state)
185
- elif new_state == SITUACAO_EDOC_A_ENVIAR:
186
- self._exec_after_SITUACAO_EDOC_A_ENVIAR(old_state, new_state)
187
- elif new_state == SITUACAO_EDOC_ENVIADA:
188
- self._exec_after_SITUACAO_EDOC_ENVIADA(old_state, new_state)
189
- elif new_state == SITUACAO_EDOC_REJEITADA:
190
- self._exec_after_SITUACAO_EDOC_REJEITADA(old_state, new_state)
191
- elif new_state == SITUACAO_EDOC_AUTORIZADA:
192
- self._exec_after_SITUACAO_EDOC_AUTORIZADA(old_state, new_state)
193
- elif new_state == SITUACAO_EDOC_CANCELADA:
194
- self._exec_after_SITUACAO_EDOC_CANCELADA(old_state, new_state)
195
- elif new_state == SITUACAO_EDOC_DENEGADA:
196
- self._exec_after_SITUACAO_EDOC_DENEGADA(old_state, new_state)
197
- elif new_state == SITUACAO_EDOC_INUTILIZADA:
198
- self._exec_after_SITUACAO_EDOC_INUTILIZADA(old_state, new_state)
199
-
200
- self._generates_subsequent_operations()
201
-
202
- def _change_state(self, new_state, force_change=False):
203
- """Método para alterar o estado do documento fiscal, mantendo a
204
- integridade do workflow da invoice.
205
-
206
- Tenha muito cuidado ao alterar o workflow da invoice manualmente,
207
- prefira alterar o estado do documento fiscal e ele se encarregar de
208
- alterar o estado da invoice.
209
-
210
- :param new_state: Novo estado
211
- :return: status: Status da conclusão da mudança de estado
212
- """
213
-
214
- status = False
215
- for record in self:
216
- old_state = record.state_edoc
217
-
218
- if force_change or record._avaliable_transition(old_state, new_state):
219
- pass
220
- else:
221
- raise UserError(
222
- _(
223
- "Não é possível realizar esta operação,\n"
224
- "esta transição não é permitida:\n\n"
225
- "De: {old_state}\n\n Para: {new_state}"
226
- ).format(old_state=old_state, new_state=new_state)
227
- )
228
-
229
- if record._before_change_state(old_state, new_state):
230
- record.state_edoc = new_state
231
- record._after_change_state(old_state, new_state)
232
- status = True
233
-
234
- return status
235
-
236
- def _document_date(self):
237
- if not self.document_date:
238
- self.document_date = self._date_server_format()
239
- if not self.date_in_out:
240
- self.date_in_out = self._date_server_format()
241
-
242
- def _document_check(self):
243
- return True
244
-
245
- def _generate_key(self):
246
- for record in self:
247
- if record.document_type_id.code in (
248
- MODELO_FISCAL_NFE,
249
- MODELO_FISCAL_NFCE,
250
- MODELO_FISCAL_CTE,
251
- ):
252
- date = fields.Datetime.context_timestamp(record, record.document_date)
253
- chave_edoc = ChaveEdoc(
254
- ano_mes=date.strftime("%y%m").zfill(4),
255
- cnpj_cpf_emitente=record.company_cnpj_cpf,
256
- codigo_uf=(
257
- record.company_state_id
258
- and record.company_state_id.ibge_code
259
- or ""
260
- ),
261
- forma_emissao=1, # TODO: Implementar campo no Odoo
262
- modelo_documento=record.document_type_id.code or "",
263
- numero_documento=record.document_number or "",
264
- numero_serie=record.document_serie or "",
265
- validar=False,
266
- )
267
- # TODO: Implementar campos no Odoo
268
- # record.key_number = chave_edoc.campos
269
- # record.key_formated = ' '.joint(chave_edoc.partes())
270
- record.document_key = chave_edoc.chave
271
-
272
- def _document_number(self):
273
- self.ensure_one()
274
- if self.issuer == DOCUMENT_ISSUER_COMPANY:
275
- if self.document_serie_id:
276
- self.document_serie = self.document_serie_id.code
277
-
278
- if self.document_type == MODELO_FISCAL_NFSE and not self.rps_number:
279
- self.rps_number = self.document_serie_id.next_seq_number()
280
-
281
- if (
282
- self.document_type != MODELO_FISCAL_NFSE
283
- and not self.document_number
284
- ):
285
- self.document_number = self.document_serie_id.next_seq_number()
286
-
287
- if not self.operation_name:
288
- self.operation_name = ", ".join(
289
- [
290
- line.name
291
- for line in self.fiscal_line_ids.mapped("fiscal_operation_id")
292
- ]
293
- )
294
-
295
- if self.document_electronic and not self.document_key:
296
- self._generate_key()
297
-
298
- def _document_confirm(self):
299
- if self.issuer == DOCUMENT_ISSUER_COMPANY:
300
- if not self.comment_ids and self.fiscal_operation_id.comment_ids:
301
- self.comment_ids |= self.fiscal_operation_id.comment_ids
302
-
303
- for line in self.fiscal_line_ids:
304
- if not line.comment_ids and line.fiscal_operation_line_id.comment_ids:
305
- line.comment_ids |= line.fiscal_operation_line_id.comment_ids
306
- self._change_state(SITUACAO_EDOC_A_ENVIAR)
307
- else:
308
- self._change_state(SITUACAO_EDOC_AUTORIZADA)
309
-
310
- def _document_confirm_to_send(self):
311
- to_confirm = self.filtered(lambda inv: inv.state_edoc != SITUACAO_EDOC_A_ENVIAR)
312
- if to_confirm:
313
- to_confirm._document_confirm()
314
-
315
- def action_document_confirm(self):
316
- self._document_confirm_to_send()
317
-
318
- def _no_eletronic_document_send(self):
319
- self._change_state(SITUACAO_EDOC_AUTORIZADA)
320
-
321
- def _document_export(self):
322
- pass
323
-
324
- def action_document_send(self):
325
- to_send = self.filtered(
326
- lambda d: d.state_edoc
327
- in (
328
- SITUACAO_EDOC_A_ENVIAR,
329
- SITUACAO_EDOC_ENVIADA,
330
- SITUACAO_EDOC_REJEITADA,
331
- )
332
- )
333
- if to_send:
334
- to_send._document_send()
335
-
336
- def document_back2draft(self):
337
- self.xml_error_message = False
338
- self.file_report_id = False
339
- if self.issuer == DOCUMENT_ISSUER_COMPANY:
340
- self._change_state(SITUACAO_EDOC_EM_DIGITACAO)
341
- else:
342
- self.state_edoc = SITUACAO_EDOC_EM_DIGITACAO
343
-
344
- def action_document_back2draft(self):
345
- self.document_back2draft()
346
-
347
- def _document_cancel(self, justificative):
348
- self.ensure_one()
349
- self.cancel_reason = justificative
350
- if self._change_state(SITUACAO_EDOC_CANCELADA):
351
- self.cancel_reason = justificative
352
-
353
- def action_document_cancel(self):
354
- self.ensure_one()
355
- if self.issuer == DOCUMENT_ISSUER_COMPANY:
356
- if self.state_edoc == SITUACAO_EDOC_AUTORIZADA:
357
- result = self.env["ir.actions.act_window"]._for_xml_id(
358
- "l10n_br_fiscal.document_cancel_wizard_action"
359
- )
360
- return result
361
- else:
362
- self.state_edoc = SITUACAO_EDOC_CANCELADA
363
-
364
- def action_document_invalidate(self):
365
- self.ensure_one()
366
- if (
367
- self.document_number
368
- and self.document_serie
369
- and self.state_edoc
370
- in (
371
- SITUACAO_EDOC_EM_DIGITACAO,
372
- SITUACAO_EDOC_REJEITADA,
373
- SITUACAO_EDOC_A_ENVIAR,
374
- )
375
- and self.issuer == DOCUMENT_ISSUER_COMPANY
376
- ):
377
- return self.env["ir.actions.act_window"]._for_xml_id(
378
- "l10n_br_fiscal.invalidate_number_wizard_action"
379
- )
380
- else:
381
- raise UserError(_("You cannot invalidate this document"))
382
-
383
- def _document_correction(self, justificative):
384
- self.ensure_one()
385
- self.correction_reason = justificative
386
-
387
- def action_document_correction(self):
388
- self.ensure_one()
389
- if (
390
- self.state_edoc in SITUACAO_EDOC_AUTORIZADA
391
- and self.issuer == DOCUMENT_ISSUER_COMPANY
392
- ):
393
- return self.env["ir.actions.act_window"]._for_xml_id(
394
- "l10n_br_fiscal.document_correction_wizard_action"
395
- )
396
- else:
397
- raise UserError(
398
- _(
399
- "You cannot create a fiscal correction document if "
400
- "this fical document you are not the document issuer"
401
- )
402
- )
@@ -1,18 +0,0 @@
1
- # Copyright (C) 2019 Renato Lima - Akretion
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- from odoo import fields, models
5
-
6
-
7
- # pylint: disable=consider-merging-classes-inherited
8
- class NCM(models.Model):
9
- _inherit = "l10n_br_fiscal.ncm"
10
-
11
- cest_ids = fields.Many2many(
12
- comodel_name="l10n_br_fiscal.cest",
13
- relation="fiscal_cest_ncm_rel",
14
- column1="ncm_id",
15
- column2="cest_id",
16
- readonly=True,
17
- string="CESTs",
18
- )
@@ -1,18 +0,0 @@
1
- # Copyright (C) 2020 Renato Lima - Akretion
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- from odoo import fields, models
5
-
6
-
7
- # pylint: disable=consider-merging-classes-inherited
8
- class NCM(models.Model):
9
- _inherit = "l10n_br_fiscal.ncm"
10
-
11
- nbm_ids = fields.Many2many(
12
- comodel_name="l10n_br_fiscal.nbm",
13
- relation="fiscal_nbm_ncm_rel",
14
- column1="ncm_id",
15
- column2="nbm_id",
16
- readonly=True,
17
- string="NBMs",
18
- )
@@ -1,18 +0,0 @@
1
- # Copyright (C) 2019 Renato Lima - Akretion
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- from odoo import fields, models
5
-
6
-
7
- # pylint: disable=consider-merging-classes-inherited
8
- class NCM(models.Model):
9
- _inherit = "l10n_br_fiscal.ncm"
10
-
11
- piscofins_ids = fields.Many2many(
12
- comodel_name="l10n_br_fiscal.tax.pis.cofins",
13
- relation="fiscal_pis_cofins_ncm_rel",
14
- column1="ncm_id",
15
- column2="piscofins_id",
16
- readonly=True,
17
- string="PIS/COFINS",
18
- )
@@ -1,119 +0,0 @@
1
- # Copyright (C) 2023 Renato Lima - Akretion
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- from odoo import _, api, fields, models
5
- from odoo.exceptions import ValidationError
6
-
7
- from ..constants.icms import ICMS_TAX_BENEFIT_TYPE
8
-
9
-
10
- # pylint: disable=consider-merging-classes-inherited
11
- class TaxDefinitionBenefit(models.Model):
12
- _inherit = "l10n_br_fiscal.tax.definition"
13
-
14
- is_benefit = fields.Boolean(
15
- string="Benefit?",
16
- readonly=True,
17
- states={"draft": [("readonly", False)]},
18
- )
19
-
20
- code = fields.Char(
21
- size=8,
22
- states={"draft": [("readonly", False)]},
23
- )
24
-
25
- name = fields.Char(
26
- states={"draft": [("readonly", False)]},
27
- )
28
-
29
- description = fields.Text(
30
- states={"draft": [("readonly", False)]},
31
- )
32
-
33
- benefit_type = fields.Selection(
34
- selection=ICMS_TAX_BENEFIT_TYPE,
35
- states={"draft": [("readonly", False)]},
36
- )
37
-
38
- # Anexo RICMS
39
- # Informar o anexo do Regulamento do ICMS.
40
-
41
- # Artigo
42
- # Informar o artigo referente ao enquadramento legal da operação
43
- # ou prestação geradora de crédito acumulado.
44
-
45
- # Inciso
46
- # Informar o inciso referente ao enquadramento legal da operação
47
- # ou prestação geradora de crédito acumulado.
48
-
49
- # Alínea
50
- # Alínea referente ao enquadramento legal da operação ou prestação
51
- # geradora de crédito acumulado.
52
-
53
- # Parágrafo
54
- # Informar o parágrafo referente ao enquadramento legal da operação
55
- # ou prestação geradora de crédito acumulado.
56
-
57
- # Item RICMS
58
- # Informar o item do Regulamento do ICMS.
59
-
60
- # Letra RICMS
61
- # Informar a letra do Regulamento do ICMS.
62
-
63
- def _get_search_domain(self, tax_definition):
64
- """Create domain to be used in contraints methods"""
65
- domain = super()._get_search_domain(tax_definition)
66
- if tax_definition.icms_regulation_id and tax_definition.is_benefit:
67
- domain.append(
68
- ("is_benefit", "=", tax_definition.is_benefit),
69
- )
70
-
71
- if tax_definition.ncm_ids:
72
- domain.append(
73
- ("ncm_ids", "in", tax_definition.ncm_ids.ids),
74
- )
75
-
76
- if tax_definition.cest_ids:
77
- domain.append(
78
- ("cest_ids", "in", tax_definition.cest_ids.ids),
79
- )
80
-
81
- if tax_definition.nbm_ids:
82
- domain.append(
83
- ("nbm_ids", "in", tax_definition.nbm_ids.ids),
84
- )
85
-
86
- if tax_definition.product_ids:
87
- domain.append(
88
- ("product_ids", "in", tax_definition.product_ids.ids),
89
- )
90
-
91
- if tax_definition.ncm_exception:
92
- domain.append(
93
- ("ncm_exception", "=", tax_definition.ncm_exception),
94
- )
95
-
96
- return domain
97
-
98
- @api.constrains("is_benefit", "code", "benefit_type", "state_from_id")
99
- def _check_tax_benefit_code(self):
100
- for record in self:
101
- if record.is_benefit:
102
- if record.code:
103
- if len(record.code) != 8:
104
- raise ValidationError(
105
- _("Tax benefit code must be 8 characters!")
106
- )
107
-
108
- if record.code[:2].upper() != record.state_from_id.code.upper():
109
- raise ValidationError(
110
- _("Tax benefit code must be start with state code!")
111
- )
112
-
113
- if record.code[3:4] != record.benefit_type:
114
- raise ValidationError(
115
- _(
116
- "The tax benefit code must contain "
117
- "the type of benefit!"
118
- )
119
- )
@@ -1,36 +0,0 @@
1
- # Copyright (C) 2019 Renato Lima - Akretion
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- from odoo import _, api, fields, models
5
- from odoo.exceptions import ValidationError
6
-
7
-
8
- # pylint: disable=consider-merging-classes-inherited
9
- class TaxDefinitionCFOP(models.Model):
10
- _inherit = "l10n_br_fiscal.tax.definition"
11
-
12
- cfop_id = fields.Many2one(comodel_name="l10n_br_fiscal.cfop", string="CFOP")
13
-
14
- @api.constrains("cfop_id")
15
- def _check_cfop_id(self):
16
- for record in self:
17
- if record.cfop_id:
18
- domain = [
19
- ("id", "!=", record.id),
20
- ("cfop_id", "=", record.cfop_id.id),
21
- ("tax_group_id", "=", record.tax_group_id.id),
22
- ("tax_id", "=", record.tax_id.id),
23
- ]
24
-
25
- if record.env["l10n_br_fiscal.tax.definition"].search_count(domain):
26
- raise ValidationError(
27
- _(
28
- "Tax Definition already exists "
29
- "for this CFOP and Tax Group !"
30
- )
31
- )
32
-
33
- @api.onchange("cfop_id")
34
- def _onchange_cfop_id(self):
35
- if self.cfop_id:
36
- self.type_in_out = self.cfop_id.type_in_out
@@ -1,29 +0,0 @@
1
- # Copyright (C) 2019 Renato Lima - Akretion
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- from odoo import _, api, models
5
- from odoo.exceptions import ValidationError
6
-
7
-
8
- # pylint: disable=consider-merging-classes-inherited
9
- class TaxDefinitionCompany(models.Model):
10
- _inherit = "l10n_br_fiscal.tax.definition"
11
-
12
- @api.constrains("company_id")
13
- def _check_company_id(self):
14
- for record in self:
15
- if record.company_id:
16
- domain = [
17
- ("id", "!=", record.id),
18
- ("company_id", "=", record.company_id.id),
19
- ("tax_group_id", "=", record.tax_group_id.id),
20
- ("tax_id", "=", record.tax_id.id),
21
- ]
22
-
23
- if record.env["l10n_br_fiscal.tax.definition"].search_count(domain):
24
- raise ValidationError(
25
- _(
26
- "Tax Definition already exists "
27
- "for this Company and Tax Group !"
28
- )
29
- )
@@ -1,36 +0,0 @@
1
- # Copyright (C) 2019 Renato Lima - Akretion
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- from odoo import _, api, fields, models
5
- from odoo.exceptions import ValidationError
6
-
7
-
8
- # pylint: disable=consider-merging-classes-inherited
9
- class TaxDefinitionICMS(models.Model):
10
- _inherit = "l10n_br_fiscal.tax.definition"
11
-
12
- icms_regulation_id = fields.Many2one(
13
- comodel_name="l10n_br_fiscal.icms.regulation", string="ICMS Regulation"
14
- )
15
-
16
- def _get_search_domain(self, tax_definition):
17
- """Create domain to be used in contraints methods"""
18
- domain = super()._get_search_domain(tax_definition)
19
- if tax_definition.icms_regulation_id:
20
- domain.append(
21
- ("icms_regulation_id", "=", tax_definition.icms_regulation_id.id),
22
- )
23
- return domain
24
-
25
- @api.constrains("icms_regulation_id", "state_from_id")
26
- def _check_icms(self):
27
- for record in self:
28
- if record.icms_regulation_id:
29
- domain = self._get_search_domain(record)
30
- if record.env["l10n_br_fiscal.tax.definition"].search_count(domain):
31
- raise ValidationError(
32
- _(
33
- "Tax Definition already exists "
34
- "for this ICMS and Tax Group !"
35
- )
36
- )