odoo-addon-l10n-br-fiscal-edi 16.0.1.5.2__py3-none-any.whl → 16.0.1.6.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.
- odoo/addons/l10n_br_fiscal_edi/README.rst +1 -1
- odoo/addons/l10n_br_fiscal_edi/__manifest__.py +1 -3
- odoo/addons/l10n_br_fiscal_edi/i18n/l10n_br_fiscal_edi.pot +0 -101
- odoo/addons/l10n_br_fiscal_edi/security/ir.model.access.csv +0 -1
- odoo/addons/l10n_br_fiscal_edi/static/description/index.html +1 -1
- odoo/addons/l10n_br_fiscal_edi/wizards/__init__.py +0 -1
- {odoo_addon_l10n_br_fiscal_edi-16.0.1.5.2.dist-info → odoo_addon_l10n_br_fiscal_edi-16.0.1.6.0.dist-info}/METADATA +2 -2
- {odoo_addon_l10n_br_fiscal_edi-16.0.1.5.2.dist-info → odoo_addon_l10n_br_fiscal_edi-16.0.1.6.0.dist-info}/RECORD +10 -14
- {odoo_addon_l10n_br_fiscal_edi-16.0.1.5.2.dist-info → odoo_addon_l10n_br_fiscal_edi-16.0.1.6.0.dist-info}/WHEEL +1 -1
- odoo/addons/l10n_br_fiscal_edi/tests/test_fiscal_document_generic.py +0 -1173
- odoo/addons/l10n_br_fiscal_edi/tests/test_tax_benefit.py +0 -76
- odoo/addons/l10n_br_fiscal_edi/wizards/document_import_wizard_mixin.py +0 -132
- odoo/addons/l10n_br_fiscal_edi/wizards/document_import_wizard_mixin.xml +0 -44
- {odoo_addon_l10n_br_fiscal_edi-16.0.1.5.2.dist-info → odoo_addon_l10n_br_fiscal_edi-16.0.1.6.0.dist-info}/top_level.txt +0 -0
@@ -1,76 +0,0 @@
|
|
1
|
-
# Copyright 2023 Akretion - Renato Lima <renato.lima@akretion.com.br>
|
2
|
-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
3
|
-
|
4
|
-
from odoo import Command
|
5
|
-
from odoo.tests import TransactionCase
|
6
|
-
|
7
|
-
from ..constants.fiscal import SITUACAO_EDOC_A_ENVIAR
|
8
|
-
|
9
|
-
|
10
|
-
class TestTaxBenefit(TransactionCase):
|
11
|
-
@classmethod
|
12
|
-
def setUpClass(cls):
|
13
|
-
super().setUpClass()
|
14
|
-
cls.nfe_tax_benefit = cls.env.ref("l10n_br_fiscal.demo_nfe_tax_benefit")
|
15
|
-
cls.tax_benefit = cls.env["l10n_br_fiscal.tax.definition"].create(
|
16
|
-
{
|
17
|
-
"icms_regulation_id": cls.env.ref(
|
18
|
-
"l10n_br_fiscal.tax_icms_regulation"
|
19
|
-
).id,
|
20
|
-
"tax_group_id": cls.env.ref("l10n_br_fiscal.tax_group_icms").id,
|
21
|
-
"code": "SP810001",
|
22
|
-
"name": "TAX BENEFIT DEMO",
|
23
|
-
"description": "TAX BENEFIT DEMO",
|
24
|
-
"benefit_type": "1",
|
25
|
-
"is_benefit": True,
|
26
|
-
"is_taxed": True,
|
27
|
-
"is_debit_credit": True,
|
28
|
-
"custom_tax": True,
|
29
|
-
"tax_id": cls.env.ref("l10n_br_fiscal.tax_icms_12_red_26_57").id,
|
30
|
-
"cst_id": cls.env.ref("l10n_br_fiscal.cst_icms_20").id,
|
31
|
-
"state_from_id": cls.env.ref("base.state_br_sp").id,
|
32
|
-
"state_to_ids": [Command.set(cls.env.ref("base.state_br_mg").ids)],
|
33
|
-
"ncms": "73269090",
|
34
|
-
"ncm_ids": [
|
35
|
-
Command.set(cls.env.ref("l10n_br_fiscal.ncm_73269090").ids)
|
36
|
-
],
|
37
|
-
"state": "approved",
|
38
|
-
}
|
39
|
-
)
|
40
|
-
|
41
|
-
def test_nfe_tax_benefit(self):
|
42
|
-
"""Test NFe with tax benefit."""
|
43
|
-
|
44
|
-
self.nfe_tax_benefit._onchange_fiscal_operation_id()
|
45
|
-
|
46
|
-
for line in self.nfe_tax_benefit.fiscal_line_ids:
|
47
|
-
line._onchange_product_id_fiscal()
|
48
|
-
line._onchange_commercial_quantity()
|
49
|
-
line._onchange_fiscal_operation_id()
|
50
|
-
line._onchange_fiscal_operation_line_id()
|
51
|
-
line._onchange_fiscal_taxes()
|
52
|
-
|
53
|
-
self.assertEqual(
|
54
|
-
line.icms_tax_benefit_id,
|
55
|
-
self.tax_benefit,
|
56
|
-
"Document line must have tax benefit",
|
57
|
-
)
|
58
|
-
|
59
|
-
# self.nfe_tax_benefit.action_document_confirm()
|
60
|
-
|
61
|
-
self.assertEqual(
|
62
|
-
self.nfe_tax_benefit.state_edoc,
|
63
|
-
SITUACAO_EDOC_A_ENVIAR,
|
64
|
-
"Document is not in To Send state",
|
65
|
-
)
|
66
|
-
|
67
|
-
self.nfe_tax_benefit.action_document_send()
|
68
|
-
|
69
|
-
# self.assertEqual(
|
70
|
-
# self.nfe_tax_benefit.state_edoc,
|
71
|
-
# SITUACAO_EDOC_AUTORIZADA,
|
72
|
-
# "Document is not in Authorized state",
|
73
|
-
# )
|
74
|
-
|
75
|
-
# result = self.nfe_tax_benefit.action_document_cancel()
|
76
|
-
# self.assertTrue(result)
|
@@ -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 odoo.addons.l10n_br_fiscal.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>
|