odoo-addon-l10n-br-fiscal 18.0.5.0.0.1__py3-none-any.whl → 18.0.7.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.
- odoo/addons/l10n_br_fiscal/README.rst +1 -1
- odoo/addons/l10n_br_fiscal/__manifest__.py +6 -2
- odoo/addons/l10n_br_fiscal/constants/fiscal.py +18 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.cest.csv +1043 -983
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.cst.csv +58 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.operation.indicator.csv +27 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.tax.classification.csv +163 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.tax.csv +31 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.tax.group.csv +3 -0
- odoo/addons/l10n_br_fiscal/i18n/l10n_br_fiscal.pot +523 -43
- odoo/addons/l10n_br_fiscal/i18n/pt_BR.po +523 -44
- odoo/addons/l10n_br_fiscal/models/__init__.py +2 -2
- odoo/addons/l10n_br_fiscal/models/data_abstract.py +9 -6
- odoo/addons/l10n_br_fiscal/models/document_line_mixin.py +993 -8
- odoo/addons/l10n_br_fiscal/models/document_mixin.py +236 -1
- odoo/addons/l10n_br_fiscal/models/operation_indicator.py +58 -0
- odoo/addons/l10n_br_fiscal/models/operation_line.py +28 -0
- odoo/addons/l10n_br_fiscal/models/product_template.py +4 -0
- odoo/addons/l10n_br_fiscal/models/res_company.py +17 -0
- odoo/addons/l10n_br_fiscal/models/res_partner.py +10 -0
- odoo/addons/l10n_br_fiscal/models/simplified_tax_range.py +8 -0
- odoo/addons/l10n_br_fiscal/models/tax_classification.py +81 -0
- odoo/addons/l10n_br_fiscal/security/ir.model.access.csv +7 -1
- odoo/addons/l10n_br_fiscal/static/description/index.html +1 -1
- odoo/addons/l10n_br_fiscal/tests/__init__.py +1 -0
- odoo/addons/l10n_br_fiscal/tests/test_tax_classification.py +110 -0
- odoo/addons/l10n_br_fiscal/views/document_line_mixin_view.xml +106 -4
- odoo/addons/l10n_br_fiscal/views/document_line_view.xml +4 -0
- odoo/addons/l10n_br_fiscal/views/document_view.xml +14 -0
- odoo/addons/l10n_br_fiscal/views/icms_regulation_view.xml +1 -5
- odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_action.xml +30 -0
- odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_menu.xml +16 -0
- odoo/addons/l10n_br_fiscal/views/nbs_view.xml +1 -5
- odoo/addons/l10n_br_fiscal/views/ncm_view.xml +1 -5
- odoo/addons/l10n_br_fiscal/views/operation_indicator_view.xml +75 -0
- odoo/addons/l10n_br_fiscal/views/operation_line_view.xml +4 -5
- odoo/addons/l10n_br_fiscal/views/operation_view.xml +1 -5
- odoo/addons/l10n_br_fiscal/views/product_template_view.xml +5 -0
- odoo/addons/l10n_br_fiscal/views/res_company_view.xml +6 -0
- odoo/addons/l10n_br_fiscal/views/res_partner_view.xml +4 -0
- odoo/addons/l10n_br_fiscal/views/service_type_view.xml +1 -5
- odoo/addons/l10n_br_fiscal/views/tax_classification.xml +108 -0
- odoo/addons/l10n_br_fiscal/views/tax_definition_view.xml +1 -5
- odoo/addons/l10n_br_fiscal/views/tax_view.xml +2 -2
- odoo/addons/l10n_br_fiscal/wizards/__init__.py +1 -1
- odoo/addons/l10n_br_fiscal/wizards/document_import_wizard.py +234 -0
- odoo/addons/l10n_br_fiscal/wizards/{document_import_wizard_mixin.xml → document_import_wizard.xml} +26 -7
- {odoo_addon_l10n_br_fiscal-18.0.5.0.0.1.dist-info → odoo_addon_l10n_br_fiscal-18.0.7.1.0.dist-info}/METADATA +2 -2
- {odoo_addon_l10n_br_fiscal-18.0.5.0.0.1.dist-info → odoo_addon_l10n_br_fiscal-18.0.7.1.0.dist-info}/RECORD +51 -46
- odoo/addons/l10n_br_fiscal/models/document_line_mixin_methods.py +0 -818
- odoo/addons/l10n_br_fiscal/models/document_mixin_methods.py +0 -247
- odoo/addons/l10n_br_fiscal/wizards/document_import_wizard_mixin.py +0 -129
- {odoo_addon_l10n_br_fiscal-18.0.5.0.0.1.dist-info → odoo_addon_l10n_br_fiscal-18.0.7.1.0.dist-info}/WHEEL +0 -0
- {odoo_addon_l10n_br_fiscal-18.0.5.0.0.1.dist-info → odoo_addon_l10n_br_fiscal-18.0.7.1.0.dist-info}/top_level.txt +0 -0
|
@@ -41,7 +41,6 @@ class FiscalDocumentMixin(models.AbstractModel):
|
|
|
41
41
|
"""
|
|
42
42
|
|
|
43
43
|
_name = "l10n_br_fiscal.document.mixin"
|
|
44
|
-
_inherit = "l10n_br_fiscal.document.mixin.methods"
|
|
45
44
|
_description = "Document Fiscal Mixin Fields"
|
|
46
45
|
|
|
47
46
|
def _date_server_format(self):
|
|
@@ -57,6 +56,218 @@ class FiscalDocumentMixin(models.AbstractModel):
|
|
|
57
56
|
)
|
|
58
57
|
return domain
|
|
59
58
|
|
|
59
|
+
def _prepare_br_fiscal_dict(self, default=False):
|
|
60
|
+
self.ensure_one()
|
|
61
|
+
fields = self.env["l10n_br_fiscal.document.mixin"]._fields.keys()
|
|
62
|
+
|
|
63
|
+
# we now read the record fiscal fields except the m2m tax:
|
|
64
|
+
vals = self._convert_to_write(self.read(fields)[0])
|
|
65
|
+
|
|
66
|
+
# remove id field to avoid conflicts
|
|
67
|
+
vals.pop("id", None)
|
|
68
|
+
|
|
69
|
+
if default: # in case you want to use new rather than write later
|
|
70
|
+
return {f"default_{k}": vals[k] for k in vals.keys()}
|
|
71
|
+
return vals
|
|
72
|
+
|
|
73
|
+
@api.onchange("document_type_id")
|
|
74
|
+
def _onchange_document_type_id(self):
|
|
75
|
+
if self.document_type_id and self.issuer == DOCUMENT_ISSUER_COMPANY:
|
|
76
|
+
self.document_serie_id = self.document_type_id.get_document_serie(
|
|
77
|
+
self.company_id, self.fiscal_operation_id
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
@api.depends("fiscal_operation_id")
|
|
81
|
+
def _compute_document_type_id(self):
|
|
82
|
+
for doc in self.filtered(lambda doc: doc.fiscal_operation_id):
|
|
83
|
+
if doc.issuer == DOCUMENT_ISSUER_COMPANY and not doc.document_type_id:
|
|
84
|
+
doc.document_type_id = doc.company_id.document_type_id
|
|
85
|
+
|
|
86
|
+
def _get_amount_lines(self):
|
|
87
|
+
"""Get object lines instances used to compute fiscal fields"""
|
|
88
|
+
return self.mapped(self._get_fiscal_lines_field_name())
|
|
89
|
+
|
|
90
|
+
def _get_product_amount_lines(self):
|
|
91
|
+
fiscal_line_ids = self._get_amount_lines()
|
|
92
|
+
return fiscal_line_ids.filtered(lambda line: line.product_id.type != "service")
|
|
93
|
+
|
|
94
|
+
@api.model
|
|
95
|
+
def _get_amount_fields(self):
|
|
96
|
+
"""Get all fields with 'amount_' prefix"""
|
|
97
|
+
fields = self.env["l10n_br_fiscal.document.mixin"]._fields.keys()
|
|
98
|
+
prefixes = ("amount_", "fiscal_amount_")
|
|
99
|
+
amount_fields = [f for f in fields if f.startswith(prefixes)]
|
|
100
|
+
return amount_fields
|
|
101
|
+
|
|
102
|
+
@api.depends("document_serie_id", "issuer")
|
|
103
|
+
def _compute_document_serie(self):
|
|
104
|
+
for doc in self:
|
|
105
|
+
if doc.document_serie_id and doc.issuer == DOCUMENT_ISSUER_COMPANY:
|
|
106
|
+
doc.document_serie = doc.document_serie_id.code
|
|
107
|
+
elif doc.document_serie is None:
|
|
108
|
+
doc.document_serie = False
|
|
109
|
+
|
|
110
|
+
@api.depends("document_type_id", "issuer")
|
|
111
|
+
def _compute_document_serie_id(self):
|
|
112
|
+
for doc in self:
|
|
113
|
+
if (
|
|
114
|
+
not doc.document_serie_id
|
|
115
|
+
and doc.document_type_id
|
|
116
|
+
and doc.issuer == DOCUMENT_ISSUER_COMPANY
|
|
117
|
+
):
|
|
118
|
+
doc.document_serie_id = doc.document_type_id.get_document_serie(
|
|
119
|
+
doc.company_id, doc.fiscal_operation_id
|
|
120
|
+
)
|
|
121
|
+
elif doc.document_serie_id is None:
|
|
122
|
+
doc.document_serie_id = False
|
|
123
|
+
|
|
124
|
+
@api.model
|
|
125
|
+
def _get_fiscal_lines_field_name(self):
|
|
126
|
+
return "fiscal_line_ids"
|
|
127
|
+
|
|
128
|
+
def _get_fiscal_amount_field_dependencies(self):
|
|
129
|
+
"""
|
|
130
|
+
Dynamically get the list of field dependencies.
|
|
131
|
+
"""
|
|
132
|
+
if self._abstract:
|
|
133
|
+
return []
|
|
134
|
+
o2m_field_name = self._get_fiscal_lines_field_name()
|
|
135
|
+
target_fields = []
|
|
136
|
+
for field in self._get_amount_fields():
|
|
137
|
+
if (
|
|
138
|
+
field.replace("amount_", "")
|
|
139
|
+
in getattr(self, o2m_field_name)._fields.keys()
|
|
140
|
+
):
|
|
141
|
+
target_fields.append(field.replace("amount_", ""))
|
|
142
|
+
|
|
143
|
+
return [o2m_field_name] + [
|
|
144
|
+
f"{o2m_field_name}.{target_field}" for target_field in target_fields
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
@api.depends(lambda self: self._get_fiscal_amount_field_dependencies())
|
|
148
|
+
def _compute_fiscal_amount(self):
|
|
149
|
+
"""
|
|
150
|
+
Compute and sum various fiscal amounts from the document lines.
|
|
151
|
+
|
|
152
|
+
This method iterates over fields prefixed with 'amount_' (as determined
|
|
153
|
+
by `_get_amount_fields`) and sums corresponding values from the lines
|
|
154
|
+
retrieved by `_get_amount_lines`.
|
|
155
|
+
|
|
156
|
+
It handles cases where delivery costs (freight, insurance, other) are
|
|
157
|
+
defined at the document total level rather than per line.
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
fields = self._get_amount_fields()
|
|
161
|
+
for doc in self.filtered(lambda m: m.fiscal_operation_id):
|
|
162
|
+
values = {key: 0.0 for key in fields}
|
|
163
|
+
for line in doc._get_amount_lines():
|
|
164
|
+
for field in fields:
|
|
165
|
+
if field in line._fields.keys():
|
|
166
|
+
values[field] += line[field]
|
|
167
|
+
if field.replace("amount_", "") in line._fields.keys():
|
|
168
|
+
# FIXME this field creates an error in invoice form
|
|
169
|
+
if field == "amount_financial_discount_value":
|
|
170
|
+
values["amount_financial_discount_value"] += (
|
|
171
|
+
0 # line.financial_discount_value
|
|
172
|
+
)
|
|
173
|
+
else:
|
|
174
|
+
values[field] += line[field.replace("amount_", "")]
|
|
175
|
+
|
|
176
|
+
# Valores definidos pelo Total e não pela Linha
|
|
177
|
+
if (
|
|
178
|
+
doc.company_id.delivery_costs == "total"
|
|
179
|
+
or doc.force_compute_delivery_costs_by_total
|
|
180
|
+
):
|
|
181
|
+
values["amount_freight_value"] = doc.amount_freight_value
|
|
182
|
+
values["amount_insurance_value"] = doc.amount_insurance_value
|
|
183
|
+
values["amount_other_value"] = doc.amount_other_value
|
|
184
|
+
|
|
185
|
+
doc.update(values)
|
|
186
|
+
|
|
187
|
+
def _get_fiscal_partner(self):
|
|
188
|
+
"""
|
|
189
|
+
Hook method to determine the fiscal partner for the document.
|
|
190
|
+
|
|
191
|
+
This method is designed to be overridden in implementing models if the
|
|
192
|
+
partner relevant for fiscal purposes (e.g., for tax calculations,
|
|
193
|
+
final consumer status) is different from the main `partner_id`
|
|
194
|
+
of the document record. For instance, an invoice might use a specific
|
|
195
|
+
invoicing contact derived from the main partner.
|
|
196
|
+
|
|
197
|
+
:return: A `res.partner` recordset representing the fiscal partner.
|
|
198
|
+
"""
|
|
199
|
+
|
|
200
|
+
self.ensure_one()
|
|
201
|
+
return self.partner_id
|
|
202
|
+
|
|
203
|
+
@api.depends("partner_id")
|
|
204
|
+
def _compute_ind_final(self):
|
|
205
|
+
for doc in self:
|
|
206
|
+
partner = doc._get_fiscal_partner()
|
|
207
|
+
if partner:
|
|
208
|
+
doc.ind_final = partner.ind_final
|
|
209
|
+
else:
|
|
210
|
+
# Default Value
|
|
211
|
+
doc.ind_final = "1" # Yes
|
|
212
|
+
|
|
213
|
+
@api.onchange("ind_final")
|
|
214
|
+
def _inverse_ind_final(self):
|
|
215
|
+
for doc in self:
|
|
216
|
+
for line in doc._get_amount_lines():
|
|
217
|
+
if line.ind_final != doc.ind_final:
|
|
218
|
+
line.ind_final = doc.ind_final
|
|
219
|
+
|
|
220
|
+
@api.depends("fiscal_operation_id")
|
|
221
|
+
def _compute_operation_name(self):
|
|
222
|
+
for doc in self:
|
|
223
|
+
if doc.fiscal_operation_id:
|
|
224
|
+
doc.operation_name = doc.fiscal_operation_id.name
|
|
225
|
+
else:
|
|
226
|
+
doc.operation_name = False
|
|
227
|
+
|
|
228
|
+
@api.depends("fiscal_operation_id")
|
|
229
|
+
def _compute_comment_ids(self):
|
|
230
|
+
for doc in self:
|
|
231
|
+
if doc.fiscal_operation_id:
|
|
232
|
+
doc.comment_ids = doc.fiscal_operation_id.comment_ids
|
|
233
|
+
elif doc.comment_ids is None:
|
|
234
|
+
doc.comment_ids = []
|
|
235
|
+
|
|
236
|
+
def _distribute_amount_to_lines(self, amount_field_name, line_field_name):
|
|
237
|
+
for record in self:
|
|
238
|
+
if not (
|
|
239
|
+
record.delivery_costs == "total"
|
|
240
|
+
or record.force_compute_delivery_costs_by_total
|
|
241
|
+
):
|
|
242
|
+
continue
|
|
243
|
+
lines = record._get_product_amount_lines()
|
|
244
|
+
if not lines:
|
|
245
|
+
continue
|
|
246
|
+
amount_to_distribute = record[amount_field_name]
|
|
247
|
+
total_gross = sum(lines.mapped("price_gross"))
|
|
248
|
+
if total_gross > 0:
|
|
249
|
+
distributed_amount = 0
|
|
250
|
+
for line in lines[:-1]:
|
|
251
|
+
proportional_amount = record.currency_id.round(
|
|
252
|
+
amount_to_distribute * (line.price_gross / total_gross)
|
|
253
|
+
)
|
|
254
|
+
line[line_field_name] = proportional_amount
|
|
255
|
+
distributed_amount += proportional_amount
|
|
256
|
+
lines[-1][line_field_name] = amount_to_distribute - distributed_amount
|
|
257
|
+
else:
|
|
258
|
+
lines.write({line_field_name: 0.0})
|
|
259
|
+
if lines:
|
|
260
|
+
lines[0][line_field_name] = amount_to_distribute
|
|
261
|
+
|
|
262
|
+
def _inverse_amount_freight(self):
|
|
263
|
+
self._distribute_amount_to_lines("amount_freight_value", "freight_value")
|
|
264
|
+
|
|
265
|
+
def _inverse_amount_insurance(self):
|
|
266
|
+
self._distribute_amount_to_lines("amount_insurance_value", "insurance_value")
|
|
267
|
+
|
|
268
|
+
def _inverse_amount_other(self):
|
|
269
|
+
self._distribute_amount_to_lines("amount_other_value", "other_value")
|
|
270
|
+
|
|
60
271
|
fiscal_operation_id = fields.Many2one(
|
|
61
272
|
comodel_name="l10n_br_fiscal.operation",
|
|
62
273
|
string="Operation",
|
|
@@ -134,6 +345,30 @@ class FiscalDocumentMixin(models.AbstractModel):
|
|
|
134
345
|
store=True,
|
|
135
346
|
)
|
|
136
347
|
|
|
348
|
+
amount_ibs_base = fields.Monetary(
|
|
349
|
+
string="IBS Base",
|
|
350
|
+
compute="_compute_fiscal_amount",
|
|
351
|
+
store=True,
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
amount_ibs_value = fields.Monetary(
|
|
355
|
+
string="IBS Value",
|
|
356
|
+
compute="_compute_fiscal_amount",
|
|
357
|
+
store=True,
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
amount_cbs_base = fields.Monetary(
|
|
361
|
+
string="CBS Base",
|
|
362
|
+
compute="_compute_fiscal_amount",
|
|
363
|
+
store=True,
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
amount_cbs_value = fields.Monetary(
|
|
367
|
+
string="CBS Value",
|
|
368
|
+
compute="_compute_fiscal_amount",
|
|
369
|
+
store=True,
|
|
370
|
+
)
|
|
371
|
+
|
|
137
372
|
amount_icms_base = fields.Monetary(
|
|
138
373
|
string="ICMS Base",
|
|
139
374
|
compute="_compute_fiscal_amount",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright (C) 2025 Marcel Savegnago <https://escodoo.com.br>
|
|
2
|
+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
|
3
|
+
|
|
4
|
+
from odoo import fields, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class OperationIndicator(models.Model):
|
|
8
|
+
"""Operation Indicator
|
|
9
|
+
|
|
10
|
+
This model stores the Operation Indicators (cIndOp) table according to
|
|
11
|
+
Annex VII of Technical Note No. 004/2025 from NFS-e Nacional, which is
|
|
12
|
+
part of the Brazilian Tax Reform (Reforma Tributária do Consumo).
|
|
13
|
+
|
|
14
|
+
The cIndOp field is used in the Service Provision Declaration (DPS)
|
|
15
|
+
to categorize consumption operations, as required by Art. 11 of
|
|
16
|
+
Complementary Law No. 214/2025.
|
|
17
|
+
|
|
18
|
+
This table will become mandatory from January 1, 2026.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
_name = "l10n_br_fiscal.operation.indicator"
|
|
22
|
+
_inherit = "l10n_br_fiscal.data.abstract"
|
|
23
|
+
_description = "Operation Indicator"
|
|
24
|
+
_order = "code"
|
|
25
|
+
|
|
26
|
+
code = fields.Char(
|
|
27
|
+
string="Operation Indicator Code",
|
|
28
|
+
required=True,
|
|
29
|
+
index=True,
|
|
30
|
+
size=6,
|
|
31
|
+
help="Operation indicator code according to Annex VII of NT 004/2025 "
|
|
32
|
+
"(e.g., 020101, 030101)",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
operation_type = fields.Text(
|
|
36
|
+
required=True,
|
|
37
|
+
help="Type of operation according to Art. 11 of Complementary Law "
|
|
38
|
+
"No. 214/2025",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
operation_location = fields.Text(
|
|
42
|
+
string="Operation Location Consideration",
|
|
43
|
+
help="Where the operation is considered to take place according to "
|
|
44
|
+
"the legislation",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
supply_characteristic = fields.Text(
|
|
48
|
+
help="Specific characteristic of the supply execution that determines "
|
|
49
|
+
"the place of supply",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
supply_location = fields.Text(
|
|
53
|
+
string="DFe Supply Location",
|
|
54
|
+
required=True,
|
|
55
|
+
help="Place of supply to be identified in the Digital Fiscal Document "
|
|
56
|
+
"(DFe), such as supplier establishment, acquirer address, "
|
|
57
|
+
"recipient address, or other locations depending on the operation",
|
|
58
|
+
)
|
|
@@ -37,6 +37,11 @@ class OperationLine(models.Model):
|
|
|
37
37
|
|
|
38
38
|
document_type_id = fields.Many2one(comodel_name="l10n_br_fiscal.document.type")
|
|
39
39
|
|
|
40
|
+
tax_classification_id = fields.Many2one(
|
|
41
|
+
comodel_name="l10n_br_fiscal.tax.classification",
|
|
42
|
+
string="Tax Classification",
|
|
43
|
+
)
|
|
44
|
+
|
|
40
45
|
cfop_internal_id = fields.Many2one(
|
|
41
46
|
comodel_name="l10n_br_fiscal.cfop",
|
|
42
47
|
string="CFOP Internal",
|
|
@@ -167,6 +172,13 @@ class OperationLine(models.Model):
|
|
|
167
172
|
cfop = self.cfop_export_id
|
|
168
173
|
return cfop
|
|
169
174
|
|
|
175
|
+
def _get_tax_classification(self, company):
|
|
176
|
+
if self.tax_classification_id:
|
|
177
|
+
return self.tax_classification_id
|
|
178
|
+
elif company.tax_classification_id:
|
|
179
|
+
return company.tax_classification_id
|
|
180
|
+
return self.env["l10n_br_fiscal.tax.classification"]
|
|
181
|
+
|
|
170
182
|
def _build_mapping_result_ipi(self, mapping_result, tax_definition):
|
|
171
183
|
if tax_definition and tax_definition.ipi_guideline_id:
|
|
172
184
|
mapping_result["ipi_guideline"] = tax_definition.ipi_guideline_id
|
|
@@ -246,12 +258,15 @@ class OperationLine(models.Model):
|
|
|
246
258
|
(l10n_br_fiscal.tax.ipi.guideline).
|
|
247
259
|
- 'icms_tax_benefit_id': The determined ICMS tax benefit record
|
|
248
260
|
ID (l10n_br_fiscal.tax.definition) or False.
|
|
261
|
+
- 'tax_classification': The determined Tax Classification record
|
|
262
|
+
(l10n_br_fiscal.tax.classification).
|
|
249
263
|
"""
|
|
250
264
|
mapping_result = {
|
|
251
265
|
"taxes": {},
|
|
252
266
|
"cfop": False,
|
|
253
267
|
"ipi_guideline": self.env.ref("l10n_br_fiscal.tax_guideline_999"),
|
|
254
268
|
"icms_tax_benefit_id": False,
|
|
269
|
+
"tax_classification": False,
|
|
255
270
|
}
|
|
256
271
|
|
|
257
272
|
self.ensure_one()
|
|
@@ -259,6 +274,9 @@ class OperationLine(models.Model):
|
|
|
259
274
|
# Define CFOP
|
|
260
275
|
mapping_result["cfop"] = self._get_cfop(company, partner)
|
|
261
276
|
|
|
277
|
+
# Define Tax Classification
|
|
278
|
+
mapping_result["tax_classification"] = self._get_tax_classification(company)
|
|
279
|
+
|
|
262
280
|
# 1 Get Tax Defs from Company
|
|
263
281
|
for tax_definition in company.tax_definition_ids.map_tax_definition(
|
|
264
282
|
company,
|
|
@@ -273,6 +291,16 @@ class OperationLine(models.Model):
|
|
|
273
291
|
):
|
|
274
292
|
self._build_mapping_result(mapping_result, tax_definition)
|
|
275
293
|
|
|
294
|
+
# 1_5 From Tax Classification
|
|
295
|
+
if mapping_result["tax_classification"]:
|
|
296
|
+
mapping_result["taxes"][
|
|
297
|
+
mapping_result["tax_classification"].tax_cbs_id.tax_domain
|
|
298
|
+
] = mapping_result["tax_classification"].tax_cbs_id
|
|
299
|
+
|
|
300
|
+
mapping_result["taxes"][
|
|
301
|
+
mapping_result["tax_classification"].tax_ibs_id.tax_domain
|
|
302
|
+
] = mapping_result["tax_classification"].tax_ibs_id
|
|
303
|
+
|
|
276
304
|
# 2 From NCM
|
|
277
305
|
if not ncm and product:
|
|
278
306
|
ncm = product.ncm_id
|
|
@@ -106,6 +106,10 @@ class ProductTemplate(models.Model):
|
|
|
106
106
|
comodel_name="l10n_br_fiscal.nbs", index=True, string="NBS"
|
|
107
107
|
)
|
|
108
108
|
|
|
109
|
+
operation_indicator_id = fields.Many2one(
|
|
110
|
+
comodel_name="l10n_br_fiscal.operation.indicator",
|
|
111
|
+
)
|
|
112
|
+
|
|
109
113
|
cest_id = fields.Many2one(
|
|
110
114
|
comodel_name="l10n_br_fiscal.cest",
|
|
111
115
|
index=True,
|
|
@@ -14,10 +14,12 @@ from ..constants.fiscal import (
|
|
|
14
14
|
PROCESSADOR_NENHUM,
|
|
15
15
|
PROFIT_CALCULATION,
|
|
16
16
|
PROFIT_CALCULATION_PRESUMED,
|
|
17
|
+
TAX_DOMAIN_CBS,
|
|
17
18
|
TAX_DOMAIN_COFINS,
|
|
18
19
|
TAX_DOMAIN_COFINS_WH,
|
|
19
20
|
TAX_DOMAIN_CSLL,
|
|
20
21
|
TAX_DOMAIN_CSLL_WH,
|
|
22
|
+
TAX_DOMAIN_IBS,
|
|
21
23
|
TAX_DOMAIN_ICMS,
|
|
22
24
|
TAX_DOMAIN_ICMS_SN,
|
|
23
25
|
TAX_DOMAIN_INSS,
|
|
@@ -297,6 +299,11 @@ class ResCompany(models.Model):
|
|
|
297
299
|
domain=[("tax_domain", "=", TAX_DOMAIN_INSS_WH)],
|
|
298
300
|
)
|
|
299
301
|
|
|
302
|
+
tax_classification_id = fields.Many2one(
|
|
303
|
+
comodel_name="l10n_br_fiscal.tax.classification",
|
|
304
|
+
string="Default Tax Classification",
|
|
305
|
+
)
|
|
306
|
+
|
|
300
307
|
tax_definition_ids = fields.One2many(
|
|
301
308
|
comodel_name="l10n_br_fiscal.tax.definition",
|
|
302
309
|
inverse_name="company_id",
|
|
@@ -377,6 +384,7 @@ class ResCompany(models.Model):
|
|
|
377
384
|
self.tax_icms_id = False
|
|
378
385
|
|
|
379
386
|
self._onchange_piscofins_id()
|
|
387
|
+
self._onchange_tax_classification_id()
|
|
380
388
|
self._onchange_ripi()
|
|
381
389
|
self._onchange_tax_ipi_id()
|
|
382
390
|
self._onchange_tax_icms_id()
|
|
@@ -502,3 +510,12 @@ class ResCompany(models.Model):
|
|
|
502
510
|
self._set_tax_definition(self.tax_inss_wh_id)
|
|
503
511
|
else:
|
|
504
512
|
self._del_tax_definition(TAX_DOMAIN_INSS_WH)
|
|
513
|
+
|
|
514
|
+
@api.onchange("tax_classification_id")
|
|
515
|
+
def _onchange_tax_classification_id(self):
|
|
516
|
+
if self.tax_classification_id:
|
|
517
|
+
self._set_tax_definition(self.tax_classification_id.tax_cbs_id)
|
|
518
|
+
self._set_tax_definition(self.tax_classification_id.tax_ibs_id)
|
|
519
|
+
else:
|
|
520
|
+
self._del_tax_definition(TAX_DOMAIN_CBS)
|
|
521
|
+
self._del_tax_definition(TAX_DOMAIN_IBS)
|
|
@@ -115,6 +115,16 @@ class ResPartner(models.Model):
|
|
|
115
115
|
|
|
116
116
|
rntrc_code = fields.Char(string="RNTRC Code", size=12, tracking=True)
|
|
117
117
|
|
|
118
|
+
nif_motive_absence = fields.Selection(
|
|
119
|
+
selection=[
|
|
120
|
+
("0", "Not informed in the origin note"),
|
|
121
|
+
("1", "Exemption from NIF"),
|
|
122
|
+
("2", "NIF not required"),
|
|
123
|
+
],
|
|
124
|
+
default=False,
|
|
125
|
+
string="NIF motive absence",
|
|
126
|
+
)
|
|
127
|
+
|
|
118
128
|
def _inverse_fiscal_profile(self):
|
|
119
129
|
for p in self:
|
|
120
130
|
p._onchange_fiscal_profile_id()
|
|
@@ -66,3 +66,11 @@ class SimplifiedTaxRange(models.Model):
|
|
|
66
66
|
tax_pis_percent = fields.Float(
|
|
67
67
|
string="Tax PIS Percent", digits="Fiscal Tax Percent"
|
|
68
68
|
)
|
|
69
|
+
|
|
70
|
+
tax_ibs_percent = fields.Float(
|
|
71
|
+
string="Tax IBS Percent", digits="Fiscal Tax Percent"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
tax_cbs_percent = fields.Float(
|
|
75
|
+
string="Tax CBS Percent", digits="Fiscal Tax Percent"
|
|
76
|
+
)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Copyright 2025 Marcel Savegnago <https://escodoo.com.br>
|
|
2
|
+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
3
|
+
|
|
4
|
+
from odoo import api, fields, models
|
|
5
|
+
|
|
6
|
+
from ..constants.fiscal import (
|
|
7
|
+
TAX_DOMAIN_CBS,
|
|
8
|
+
TAX_DOMAIN_IBS,
|
|
9
|
+
TAX_RATE_TYPE,
|
|
10
|
+
TAX_RATE_TYPE_DEFAULT,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TaxClassification(models.Model):
|
|
15
|
+
_name = "l10n_br_fiscal.tax.classification"
|
|
16
|
+
_inherit = "l10n_br_fiscal.data.abstract"
|
|
17
|
+
_order = "code"
|
|
18
|
+
_description = "Tax Classification"
|
|
19
|
+
|
|
20
|
+
code = fields.Char(size=8)
|
|
21
|
+
|
|
22
|
+
description = fields.Text()
|
|
23
|
+
|
|
24
|
+
cst_code_prefix_like = fields.Char(
|
|
25
|
+
compute="_compute_cst_code_prefix_like",
|
|
26
|
+
help="Helper field to filter taxes by CST code prefix (3 chars) using LIKE.",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
@api.depends("code")
|
|
30
|
+
def _compute_cst_code_prefix_like(self):
|
|
31
|
+
for rec in self:
|
|
32
|
+
prefix = (rec.code or "")[:3]
|
|
33
|
+
# Avoid matching all records when the prefix is not available yet.
|
|
34
|
+
rec.cst_code_prefix_like = (
|
|
35
|
+
f"{prefix}%" if len(prefix) == 3 else "__no_match__%"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
tax_ibs_id = fields.Many2one(
|
|
39
|
+
comodel_name="l10n_br_fiscal.tax",
|
|
40
|
+
string="Tax IBS",
|
|
41
|
+
domain=(
|
|
42
|
+
f"[('tax_domain', '=', '{TAX_DOMAIN_IBS}'), '|', "
|
|
43
|
+
"('cst_in_id.code', 'like', cst_code_prefix_like), "
|
|
44
|
+
"('cst_out_id.code', 'like', cst_code_prefix_like)]"
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
tax_cbs_id = fields.Many2one(
|
|
49
|
+
comodel_name="l10n_br_fiscal.tax",
|
|
50
|
+
string="Tax CBS",
|
|
51
|
+
domain=(
|
|
52
|
+
f"[('tax_domain', '=', '{TAX_DOMAIN_CBS}'), '|', "
|
|
53
|
+
"('cst_in_id.code', 'like', cst_code_prefix_like), "
|
|
54
|
+
"('cst_out_id.code', 'like', cst_code_prefix_like)]"
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
regular_taxation = fields.Boolean(
|
|
59
|
+
default=False,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
presumed_credit = fields.Boolean(
|
|
63
|
+
default=False,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
credit_reversal = fields.Boolean(
|
|
67
|
+
default=False,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
rate_type = fields.Selection(
|
|
71
|
+
selection=TAX_RATE_TYPE,
|
|
72
|
+
default=TAX_RATE_TYPE_DEFAULT,
|
|
73
|
+
required=True,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
document_type_ids = fields.Many2many(
|
|
77
|
+
comodel_name="l10n_br_fiscal.document.type",
|
|
78
|
+
relation="tax_classification_document_type_rel",
|
|
79
|
+
string="Related DFes",
|
|
80
|
+
help="Related Digital Fiscal Documents",
|
|
81
|
+
)
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"l10n_br_fiscal_cest_user","Fiscal CEST for User","model_l10n_br_fiscal_cest","l10n_br_fiscal.group_user",1,0,0,0
|
|
39
39
|
"l10n_br_fiscal_cest_manager","Fiscal CEST for Manager","model_l10n_br_fiscal_cest","l10n_br_fiscal.group_manager",1,0,0,0
|
|
40
40
|
"l10n_br_fiscal_cest_maintenance","Fiscal CEST for Maintenance","model_l10n_br_fiscal_cest","l10n_br_fiscal.group_data_maintenance",1,1,1,1
|
|
41
|
+
"l10n_br_fiscal_tax_classification_user","Fiscal Tax Classification for User","model_l10n_br_fiscal_tax_classification","l10n_br_fiscal.group_user",1,0,0,0
|
|
42
|
+
"l10n_br_fiscal_tax_classification_manager","Fiscal Tax Classification for Manager","model_l10n_br_fiscal_tax_classification","l10n_br_fiscal.group_manager",1,0,0,0
|
|
43
|
+
"l10n_br_fiscal_tax_classification_maintenance","Fiscal Tax Classification for Maintenance","model_l10n_br_fiscal_tax_classification","l10n_br_fiscal.group_data_maintenance",1,1,1,1
|
|
41
44
|
"l10n_br_fiscal_product_genre_user","Fiscal Fiscal Product Genre for User","model_l10n_br_fiscal_product_genre","l10n_br_fiscal.group_user",1,0,0,0
|
|
42
45
|
"l10n_br_fiscal_product_genre_manager","Fiscal Fiscal Product Genre for Manager","model_l10n_br_fiscal_product_genre","l10n_br_fiscal.group_manager",1,0,0,0
|
|
43
46
|
"l10n_br_fiscal_product_genre_maintenance","Fiscal Fiscal Product Genre for Maintenance","model_l10n_br_fiscal_product_genre","l10n_br_fiscal.group_data_maintenance",1,1,1,1
|
|
@@ -67,6 +70,9 @@
|
|
|
67
70
|
"l10n_br_fiscal_operation_line_manager","Fiscal Operation Line for Manager","model_l10n_br_fiscal_operation_line","l10n_br_fiscal.group_manager",1,1,1,1
|
|
68
71
|
"l10n_br_fiscal_operation_document_type_user","Fiscal Operation Document Type for User","model_l10n_br_fiscal_operation_document_type","l10n_br_fiscal.group_user",1,0,0,0
|
|
69
72
|
"l10n_br_fiscal_operation_document_type_manager","Fiscal Operation Document Type for Manager","model_l10n_br_fiscal_operation_document_type","l10n_br_fiscal.group_manager",1,1,1,1
|
|
73
|
+
"l10n_br_fiscal_operation_indicator_user","Operation Indicator for User","model_l10n_br_fiscal_operation_indicator","l10n_br_fiscal.group_user",1,0,0,0
|
|
74
|
+
"l10n_br_fiscal_operation_indicator_manager","Operation Indicator for Manager","model_l10n_br_fiscal_operation_indicator","l10n_br_fiscal.group_manager",1,1,1,1
|
|
75
|
+
"l10n_br_fiscal_operation_indicator_maintenance","Operation Indicator for Maintenance","model_l10n_br_fiscal_operation_indicator","l10n_br_fiscal.group_data_maintenance",1,1,1,1
|
|
70
76
|
"l10n_br_fiscal_partner_profile_user","Fiscal Partner Profile for User","model_l10n_br_fiscal_partner_profile","base.group_user",1,0,0,0
|
|
71
77
|
"l10n_br_fiscal_partner_profile_manager","Fiscal Partner Profile for Manager","model_l10n_br_fiscal_partner_profile","l10n_br_fiscal.group_manager",1,1,1,1
|
|
72
78
|
"l10n_br_fiscal_document_user","Fiscal Document for User","model_l10n_br_fiscal_document","l10n_br_fiscal.group_user",1,1,1,0
|
|
@@ -95,4 +101,4 @@
|
|
|
95
101
|
"l10n_br_fiscal_city_taxation_code_user","Fiscal City Taxation Code for User","model_l10n_br_fiscal_city_taxation_code","l10n_br_fiscal.group_user",1,1,1,0
|
|
96
102
|
"l10n_br_fiscal_city_taxation_code_manager","Fiscal City Taxation Code for Manager","model_l10n_br_fiscal_city_taxation_code","l10n_br_fiscal.group_user",1,1,1,1
|
|
97
103
|
"l10n_br_fiscal_document_status_wizard_user",l10n_br_fiscal_document_status_wizard,model_l10n_br_fiscal_document_status_wizard,base.group_user,1,1,1,1
|
|
98
|
-
"
|
|
104
|
+
"l10n_br_fiscal_document_import_wizard_user",l10n_br_fiscal_document_import_wizard_user,model_l10n_br_fiscal_document_import_wizard,base.group_user,1,1,1,1
|
|
@@ -372,7 +372,7 @@ ul.auto-toc {
|
|
|
372
372
|
!! This file is generated by oca-gen-addon-readme !!
|
|
373
373
|
!! changes will be overwritten. !!
|
|
374
374
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
375
|
-
!! source digest: sha256:
|
|
375
|
+
!! source digest: sha256:5cd8cb0b01f3ea46d8329418b2478d777a70350607e16eee38900f6a08e7e3f2
|
|
376
376
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
|
377
377
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-brazil/tree/18.0/l10n_br_fiscal"><img alt="OCA/l10n-brazil" src="https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-brazil-18-0/l10n-brazil-18-0-l10n_br_fiscal"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
|
378
378
|
<p><img alt="image" src="https://raw.githubusercontent.com/OCA/l10n-brazil/18.0/l10n_br_fiscal/static/img/fiscal_dashboard.png" /></p>
|