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,37 +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 TaxDefinitionOperationLine(models.Model):
10
- _inherit = "l10n_br_fiscal.tax.definition"
11
-
12
- fiscal_operation_line_id = fields.Many2one(
13
- comodel_name="l10n_br_fiscal.operation.line", string="Operation Line"
14
- )
15
-
16
- @api.constrains("fiscal_operation_line_id")
17
- def _check_fiscal_operation_line_id(self):
18
- for record in self:
19
- if record.fiscal_operation_line_id:
20
- domain = [
21
- ("id", "!=", record.id),
22
- (
23
- "fiscal_operation_line_id",
24
- "=",
25
- record.fiscal_operation_line_id.id,
26
- ),
27
- ("tax_group_id", "=", record.tax_group_id.id),
28
- ("tax_id", "=", record.tax_id.id),
29
- ]
30
-
31
- if record.env["l10n_br_fiscal.tax.definition"].search_count(domain):
32
- raise ValidationError(
33
- _(
34
- "Tax Definition already exists "
35
- "for this Operation Line and Tax Group !"
36
- )
37
- )
@@ -1,33 +0,0 @@
1
- # Copyright (C) 2020 Luis Felipe Mileo - KMEE
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 TaxDefinitionPartnerProfile(models.Model):
10
- _inherit = "l10n_br_fiscal.tax.definition"
11
-
12
- fiscal_profile_id = fields.Many2one(
13
- comodel_name="l10n_br_fiscal.partner.profile", string="Partner Profile"
14
- )
15
-
16
- @api.constrains("fiscal_profile_id")
17
- def _check_fiscal_profile_id(self):
18
- for record in self:
19
- if record.fiscal_profile_id:
20
- domain = [
21
- ("id", "!=", record.id),
22
- ("fiscal_profile_id", "=", record.fiscal_profile_id.id),
23
- ("tax_group_id", "=", record.tax_group_id.id),
24
- ("tax_id", "=", record.tax_id.id),
25
- ]
26
-
27
- if record.env["l10n_br_fiscal.tax.definition"].search_count(domain):
28
- raise ValidationError(
29
- _(
30
- "Tax Definition already exists "
31
- "for this Partner Profile and Tax Group !"
32
- )
33
- )
@@ -1,118 +0,0 @@
1
- # Copyright (C) 2020 KMEE INFORMATICA LTDA
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- from odoo.tests import TransactionCase
5
-
6
- from ..constants.fiscal import (
7
- SITUACAO_EDOC_A_ENVIAR,
8
- SITUACAO_EDOC_AUTORIZADA,
9
- SITUACAO_EDOC_CANCELADA,
10
- SITUACAO_EDOC_EM_DIGITACAO,
11
- SITUACAO_EDOC_REJEITADA,
12
- )
13
-
14
-
15
- class TestWorkflow(TransactionCase):
16
- @classmethod
17
- def setUpClass(cls):
18
- super().setUpClass()
19
- cls.fiscal_document = cls.env["l10n_br_fiscal.document"].create(
20
- {
21
- "document_type_id": cls.env.ref(
22
- "l10n_br_fiscal.document_55_serie_1"
23
- ).id,
24
- "fiscal_operation_type": "out",
25
- }
26
- )
27
-
28
- def test_no_electronic_01_confirm(self):
29
- self.fiscal_document.document_electronic = False
30
- assert (
31
- self.fiscal_document.state_edoc == SITUACAO_EDOC_EM_DIGITACAO
32
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
33
-
34
- self.fiscal_document.action_document_confirm()
35
- assert (
36
- self.fiscal_document.state_edoc == SITUACAO_EDOC_A_ENVIAR
37
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
38
-
39
- self.fiscal_document.action_document_send()
40
- assert (
41
- self.fiscal_document.state_edoc == SITUACAO_EDOC_AUTORIZADA
42
- ), "Error with document workflow, state 'SITUACAO_EDOC_AUTORIZADA' "
43
-
44
- def test_electronic_01_confirm(self):
45
- self.fiscal_document.document_electronic = True
46
-
47
- assert (
48
- self.fiscal_document.state_edoc == SITUACAO_EDOC_EM_DIGITACAO
49
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
50
-
51
- self.fiscal_document.action_document_confirm()
52
- assert (
53
- self.fiscal_document.state_edoc == SITUACAO_EDOC_A_ENVIAR
54
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
55
-
56
- self.fiscal_document.action_document_send()
57
- assert (
58
- self.fiscal_document.state_edoc == SITUACAO_EDOC_AUTORIZADA
59
- ), "Error with document workflow, state 'SITUACAO_EDOC_AUTORIZADA' "
60
-
61
- def test_electronic_01_rejeitada(self):
62
- self.fiscal_document.document_electronic = True
63
-
64
- assert (
65
- self.fiscal_document.state_edoc == SITUACAO_EDOC_EM_DIGITACAO
66
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
67
-
68
- self.fiscal_document.action_document_confirm()
69
- self.fiscal_document._change_state(SITUACAO_EDOC_REJEITADA)
70
-
71
- assert (
72
- self.fiscal_document.state_edoc == SITUACAO_EDOC_REJEITADA
73
- ), "Error with document workflow, state 'SITUACAO_EDOC_REJEITADA' "
74
-
75
- self.fiscal_document.action_document_send()
76
- assert (
77
- self.fiscal_document.state_edoc == SITUACAO_EDOC_AUTORIZADA
78
- ), "Error with document workflow, state 'SITUACAO_EDOC_AUTORIZADA' "
79
-
80
- def test_no_electronic_01_draft_cancel(self):
81
- self.fiscal_document.document_electronic = False
82
-
83
- assert (
84
- self.fiscal_document.state_edoc == SITUACAO_EDOC_EM_DIGITACAO
85
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
86
-
87
- self.fiscal_document._document_cancel("Test")
88
-
89
- assert (
90
- self.fiscal_document.state_edoc == SITUACAO_EDOC_CANCELADA
91
- ), "Error with document workflow, state 'SITUACAO_EDOC_REJEITADA' "
92
-
93
- def test_electronic_01_draft_cancel(self):
94
- self.fiscal_document.document_electronic = True
95
-
96
- assert (
97
- self.fiscal_document.state_edoc == SITUACAO_EDOC_EM_DIGITACAO
98
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
99
-
100
- self.fiscal_document._document_cancel("Test")
101
-
102
- assert (
103
- self.fiscal_document.state_edoc == SITUACAO_EDOC_CANCELADA
104
- ), "Error with document workflow, state 'SITUACAO_EDOC_REJEITADA' "
105
-
106
- def test_electronic_01_back2draft(self):
107
- self.fiscal_document.document_electronic = True
108
-
109
- assert (
110
- self.fiscal_document.state_edoc == SITUACAO_EDOC_EM_DIGITACAO
111
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
112
-
113
- self.fiscal_document.action_document_confirm()
114
- self.fiscal_document.action_document_back2draft()
115
-
116
- assert (
117
- self.fiscal_document.state_edoc == SITUACAO_EDOC_EM_DIGITACAO
118
- ), "Error with document workflow, state 'SITUACAO_EDOC_A_ENVIAR' "
@@ -1,15 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
2
- <odoo>
3
- <record id="action_report_document_event" model="ir.actions.report">
4
- <field name="name">Document Event</field>
5
- <field name="model">l10n_br_fiscal.event</field>
6
- <field name="report_type">qweb-pdf</field>
7
- <field name="report_name">l10n_br_fiscal.main_report_document_event</field>
8
- <field name="report_file">l10n_br_fiscal.report_document_event</field>
9
- <field
10
- name="print_report_name"
11
- >dict(object.fields_get(allfields=['type'])['type']['selection'])[object.type]</field>
12
- <field name="binding_model_id" ref="model_l10n_br_fiscal_event" />
13
- <field name="binding_type">report</field>
14
- </record>
15
- </odoo>
@@ -1,114 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
2
- <odoo>
3
- <template id="report_document_event">
4
- <t t-set="o" t-value="doc" />
5
- <t t-set="o" t-value="o.with_context(lang=o.document_id.partner_id.lang)" />
6
- <div class="page" style="font-size:16px;">
7
- <style type="text/css">
8
- .col-1,
9
- .col-2,
10
- .col-3,
11
- .col-4,
12
- .col-5,
13
- .col-6,
14
- .col-7,
15
- .col-8,
16
- .col-9,
17
- .col-10,
18
- .col-11,
19
- .col-12 {
20
- padding: 5px 5px 5px 5px;
21
- }
22
- .bt {
23
- border-top: 1px solid black;
24
- }
25
- .bb {
26
- border-bottom: 1px solid black;
27
- }
28
- .bl {
29
- border-left: 1px solid black;
30
- }
31
- .br {
32
- border-right: 1px solid black;
33
- }
34
- row {
35
- cols: 10;
36
- }
37
- </style>
38
-
39
- <div class="oe_structure" />
40
-
41
- <div id="header" class="row bt bb bl br">
42
- <div class="col-12" style="text-align: center; font-size: 36px;">
43
- <span t-field="o.type" />
44
- </div>
45
- </div>
46
- <div class="row bb bl br">
47
- <div id="document_key" class="col-6">
48
- <strong style="font-size:18px;">Document Key:</strong>
49
- <p t-field="o.document_id.document_key" />
50
- </div>
51
- <div id="company_cnpj_cpf" class="col-6 bl">
52
- <strong style="font-size:18px;">CNPJ:</strong>
53
- <p t-field="o.document_id.company_cnpj_cpf" />
54
- </div>
55
- </div>
56
- <div class="row bb bl br">
57
- <div id="document_number" class="col-3">
58
- <strong style="font-size:18px;">Document Number:</strong>
59
- <p t-field="o.document_number" />
60
- </div>
61
- <div id="document_serie_code" class="col-3 bl">
62
- <strong style="font-size:18px;">Document Serie:</strong>
63
- <p t-field="o.document_serie_id.code" />
64
- </div>
65
- <div id="environment" class="col-6 bl">
66
- <strong style="font-size:18px;">Environment:</strong>
67
- <p t-field="o.environment" />
68
- </div>
69
- </div>
70
- <div class="row bb bl br">
71
- <div id="protocol_number" class="col-6">
72
- <strong style="font-size:18px;">Protocol Number:</strong>
73
- <p t-field="o.protocol_number" />
74
- </div>
75
- <div id="protocol_date" class="col-6 bl">
76
- <strong style="font-size:18px;">Protocol Date:</strong>
77
- <p t-field="o.protocol_date" />
78
- </div>
79
- </div>
80
- <div id="justification" class="row bb bl br">
81
- <div class="col-12" t-if="o.justification">
82
- <strong style="font-size:18px;">Justification:</strong>
83
- <p t-field="o.justification" />
84
- </div>
85
- </div>
86
- <div id="cce_notes" class="row bb bl br">
87
- <div class="col-12" style="font-size:10px;" t-if="o.type == '14'">
88
- A Carta de Correção é disciplinada pelo parágrafo 1o-A do artigo 7o do Convênio S/N, de 15 de dezembro de 1970 e pode ser utilizada para regularização de erro ocorrido na emissão de documento fiscal, desde que o erro não seja relacionado com:<br
89
- />
90
- <br />
91
- I - as variáveis que determinam o valor do imposto tais como: base de cálculo, alíquota, diferença de preço, quantidade, valor da operação ou da prestação;<br
92
- />
93
- II - a correção de dados cadastrais que impliquem mudança do remetente ou do destinatário;<br
94
- />
95
- III - a data de emissão ou de saída.<br />
96
- </div>
97
- </div>
98
- </div>
99
- </template>
100
-
101
- <template id="main_report_document_event">
102
- <t t-call="web.html_container">
103
- <div class="article">
104
- <t t-foreach="docs" t-as="doc">
105
- <t
106
- t-call="l10n_br_fiscal.report_document_event"
107
- t-lang="doc.document_id.partner_id.lang"
108
- />
109
- </t>
110
- </div>
111
- </t>
112
- </template>
113
-
114
- </odoo>
@@ -1,68 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
2
- <odoo>
3
-
4
- <record id="event_search" model="ir.ui.view">
5
- <field name="name">l10n_br_fiscal.event.search</field>
6
- <field name="model">l10n_br_fiscal.event</field>
7
- <field name="arch" type="xml">
8
- <search string="Fiscal Document Event">
9
- <field name="origin" />
10
- </search>
11
- </field>
12
- </record>
13
-
14
- <record id="event_tree" model="ir.ui.view">
15
- <field name="name">l10n_br_fiscal.event.tree</field>
16
- <field name="model">l10n_br_fiscal.event</field>
17
- <field name="arch" type="xml">
18
- <tree edit="false" create="false">
19
- <field name="type" />
20
- <field name="company_id" />
21
- <field name="response" />
22
- <field name="origin" />
23
- <field name="write_date" />
24
- <field name="protocol_date" />
25
- <field name="status_code" />
26
- <field name="message" />
27
- <field name="state" />
28
- </tree>
29
- </field>
30
- </record>
31
-
32
- <record id="event_form" model="ir.ui.view">
33
- <field name="name">l10n_br_fiscal.event.form</field>
34
- <field name="model">l10n_br_fiscal.event</field>
35
- <field name="arch" type="xml">
36
- <form string="Eventos Eletronicos" edit="false" create="false">
37
- <header>
38
- <field name="state" widget="statusbar" />
39
- </header>
40
- <sheet>
41
- <group>
42
- <field name="type" />
43
- <field name="company_id" />
44
- <field name="document_id" />
45
- <field name="document_type_id" />
46
- <field name="invalidate_number_id" />
47
- <field name="sequence" />
48
- <field name="justification" />
49
- <field name="partner_id" />
50
- <field name="file_request_id" />
51
- <field name="file_response_id" />
52
- <field name="protocol_number" />
53
- <field name="lot_receipt_number" />
54
- <field name="response" />
55
- <field name="origin" />
56
- <field name="write_date" />
57
- <field name="file_path" />
58
- <field name="protocol_date" />
59
- <field name="status_code" />
60
- <field name="message" />
61
- <field name="state" />
62
- </group>
63
- </sheet>
64
- </form>
65
- </field>
66
- </record>
67
-
68
- </odoo>
@@ -1,20 +0,0 @@
1
- # Copyright 2019 KMEE
2
- # Copyright (C) 2020 Renato Lima - Akretion <renato.lima@akretion.com.br>
3
- # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4
-
5
- from odoo import models
6
-
7
-
8
- class DocumentCancelWizard(models.TransientModel):
9
- _name = "l10n_br_fiscal.document.cancel.wizard"
10
- _description = "Fiscal Document Cancel Wizard"
11
- _inherit = "l10n_br_fiscal.base.wizard.mixin"
12
-
13
- def do_cancel(self):
14
- self.document_id._document_cancel(self.justification)
15
-
16
- def doit(self):
17
- for wizard in self:
18
- if wizard.document_id:
19
- wizard.do_cancel()
20
- self._close()
@@ -1,30 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
2
- <!-- Copyright 2019 KMEE
3
- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
4
- <odoo>
5
-
6
- <record id="document_cancel_wizard_form" model="ir.ui.view">
7
- <field name="name">l10n_br_fiscal.document.cancel.wizard</field>
8
- <field name="model">l10n_br_fiscal.document.cancel.wizard</field>
9
- <field name="arch" type="xml">
10
- <form string="Cancelamento de documento fiscal">
11
- <group>
12
- <field name="justification" />
13
- </group>
14
- <footer>
15
- <button name="doit" string="OK" class="btn-primary" type="object" />
16
- <button string="Cancel" class="btn-default" special="cancel" />
17
- </footer>
18
- </form>
19
- </field>
20
- </record>
21
-
22
- <record id="document_cancel_wizard_action" model="ir.actions.act_window">
23
- <field name="name">Cancelamento de documento fiscal</field>
24
- <field name="res_model">l10n_br_fiscal.document.cancel.wizard</field>
25
- <field name="view_mode">form</field>
26
- <field name="context">{}</field>
27
- <field name="target">new</field>
28
- </record>
29
-
30
- </odoo>
@@ -1,17 +0,0 @@
1
- # Copyright 2019 KMEE
2
- # Copyright (C) 2020 Renato Lima - Akretion <renato.lima@akretion.com.br>
3
- # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4
-
5
- from odoo import models
6
-
7
-
8
- class DocumentCorrectionWizard(models.TransientModel):
9
- _name = "l10n_br_fiscal.document.correction.wizard"
10
- _description = "Fiscal Document Correction Wizard"
11
- _inherit = "l10n_br_fiscal.base.wizard.mixin"
12
-
13
- def doit(self):
14
- for wizard in self:
15
- if wizard.document_id:
16
- wizard.document_id._document_correction(wizard.justification)
17
- self._close()
@@ -1,30 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
2
- <!-- Copyright 2019 KMEE
3
- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
4
- <odoo>
5
-
6
- <record id="document_correction_wizard_form" model="ir.ui.view">
7
- <field name="name">l10n_br_fiscal.document.correction.wizard.form</field>
8
- <field name="model">l10n_br_fiscal.document.correction.wizard</field>
9
- <field name="arch" type="xml">
10
- <form string="Carta de Correção">
11
- <group>
12
- <field name="justification" />
13
- </group>
14
- <footer>
15
- <button name="doit" string="OK" class="btn-primary" type="object" />
16
- <button string="Cancel" class="btn-default" special="cancel" />
17
- </footer>
18
- </form>
19
- </field>
20
- </record>
21
-
22
- <record id="document_correction_wizard_action" model="ir.actions.act_window">
23
- <field name="name">Carta de Correção</field>
24
- <field name="res_model">l10n_br_fiscal.document.correction.wizard</field>
25
- <field name="view_mode">form</field>
26
- <field name="context">{}</field>
27
- <field name="target">new</field>
28
- </record>
29
-
30
- </odoo>
@@ -1,132 +0,0 @@
1
- # Copyright (C) 2023 Felipe Zago Rodrigues - Kmee
2
- # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3
-
4
- import base64
5
- import logging
6
-
7
- from odoo import _, api, fields, models
8
- from odoo.exceptions import UserError
9
-
10
- from ..constants.fiscal import FISCAL_IN_OUT_ALL
11
-
12
- _logger = logging.getLogger(__name__)
13
-
14
- try:
15
- from xsdata.formats.dataclass.parsers import XmlParser
16
- except ImportError:
17
- _logger.error(_("xsdata Python lib not installed!"))
18
-
19
-
20
- class DocumentImportWizardMixin(models.TransientModel):
21
- _name = "l10n_br_fiscal.document.import.wizard.mixin"
22
- _description = "Wizard Import Document Mixin"
23
- _inherit = "l10n_br_fiscal.base.wizard.mixin"
24
-
25
- company_id = fields.Many2one(
26
- comodel_name="res.company",
27
- string="Company",
28
- default=lambda self: self.env.company.id,
29
- )
30
-
31
- file = fields.Binary(string="File to Import")
32
-
33
- fiscal_operation_id = fields.Many2one(
34
- comodel_name="l10n_br_fiscal.operation",
35
- string="Fiscal Operation",
36
- domain="[('fiscal_operation_type', '=', fiscal_operation_type)]",
37
- )
38
-
39
- document_type = fields.Char()
40
-
41
- fiscal_operation_type = fields.Selection(selection=FISCAL_IN_OUT_ALL)
42
-
43
- def _import_edoc(self):
44
- self._find_existing_document()
45
- if not self.document_id:
46
- binding, self.document_id = self._create_edoc_from_file()
47
- else:
48
- binding = self._parse_file()
49
- return binding, self.document_id
50
-
51
- def action_import_and_open_document(self):
52
- self._import_edoc()
53
- return self.action_open_document()
54
-
55
- def _create_edoc_from_file(self):
56
- pass # meant to be overriden
57
-
58
- @api.onchange("file")
59
- def _onchange_file(self):
60
- if self.file:
61
- self._fill_wizard_from_binding()
62
-
63
- def _fill_wizard_from_binding(self):
64
- pass # meant to be overriden
65
-
66
- def action_open_document(self):
67
- return {
68
- "name": _("Document Imported"),
69
- "type": "ir.actions.act_window",
70
- "target": "current",
71
- "views": [[False, "form"]],
72
- "res_id": self.document_id.id,
73
- "res_model": "l10n_br_fiscal.document",
74
- }
75
-
76
- def _document_key_from_binding(self, binding):
77
- pass # meant to be overriden
78
-
79
- def _find_existing_document(self):
80
- document_key = self._document_key_from_binding(self._parse_file())
81
- self.document_id = self.env["l10n_br_fiscal.document"].search(
82
- [("document_key", "=", document_key.chave)],
83
- limit=1,
84
- )
85
-
86
- def _find_document_type(self, code):
87
- return self.env["l10n_br_fiscal.document.type"].search(
88
- [("code", "=", code)],
89
- limit=1,
90
- )
91
-
92
- def _find_fiscal_operation(self, cfop, nat_op, fiscal_operation_type):
93
- """try to find a matching fiscal operation via an operation line"""
94
- operation_lines = self.env["l10n_br_fiscal.operation.line"].search(
95
- [
96
- ("state", "=", "approved"),
97
- ("fiscal_type", "=", fiscal_operation_type),
98
- ("cfop_external_id", "=", cfop),
99
- ],
100
- )
101
- for line in operation_lines:
102
- if line.fiscal_operation_id.name == nat_op:
103
- return line.fiscal_operation_id
104
- if operation_lines:
105
- return operation_lines[0].fiscal_operation_id
106
-
107
- def _parse_file(self):
108
- return self._parse_file_data(self.file)
109
-
110
- @api.model
111
- def _parse_file_data(self, file_data):
112
- try:
113
- binding = XmlParser().from_bytes(base64.b64decode(file_data))
114
- except Exception as e:
115
- raise UserError(_("Invalid file!")) from e
116
- return binding
117
-
118
- @api.model
119
- def _detect_binding(self, binding):
120
- """
121
- A pluggable method were each specialized fiscal document
122
- importation wizard can register itself and return a tuple
123
- with (the_fiscal_document_type_code, the_name_of_the_importation_wizard)
124
- """
125
- raise UserError(
126
- _("Importation not implemented for %s!")
127
- % (
128
- type(
129
- binding,
130
- )
131
- )
132
- )
@@ -1,44 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
2
- <!-- Copyright 2023 KMEE
3
- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
4
- <odoo>
5
-
6
- <record id="l10n_br_fiscal_document_import_wizard_mixin_form" model="ir.ui.view">
7
- <field name="name">l10n_br_fiscal.document.import.wizard.mixin.form</field>
8
- <field name="model">l10n_br_fiscal.document.import.wizard.mixin</field>
9
- <field name="arch" type="xml">
10
- <form string="Import Document">
11
- <group>
12
- <field name="file" required="1" />
13
- </group>
14
- <separator
15
- string="Preview Data"
16
- attrs="{'invisible': [('file', '=', False)]}"
17
- />
18
- <group id="document_info" attrs="{'invisible': [('file', '=', False)]}">
19
- <group>
20
- <field name="fiscal_operation_id" required="1" />
21
- <field name="fiscal_operation_type" invisible="1" />
22
- <field name="document_key" readonly="1" />
23
- <field name="document_number" readonly="1" />
24
- <field name="document_serie" readonly="1" />
25
- </group>
26
-
27
- <group>
28
- <field name="partner_id" readonly="1" />
29
- </group>
30
- </group>
31
- <footer>
32
- <button
33
- name="action_import_and_open_document"
34
- string="Import Fiscal Document"
35
- class="btn-primary"
36
- type="object"
37
- />
38
- <button string="Cancel" class="btn-default" special="cancel" />
39
- </footer>
40
- </form>
41
- </field>
42
- </record>
43
-
44
- </odoo>