odoo-addon-l10n-br-fiscal 17.0.1.0.0.13__py3-none-any.whl → 17.0.4.0.0.1__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/README.rst +1 -1
- odoo/addons/l10n_br_fiscal/__manifest__.py +1 -1
- odoo/addons/l10n_br_fiscal/constants/fiscal.py +0 -20
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.document.type.csv +1 -0
- odoo/addons/l10n_br_fiscal/data/operation_data.xml +1 -1
- odoo/addons/l10n_br_fiscal/demo/fiscal_document_demo.xml +3 -91
- odoo/addons/l10n_br_fiscal/demo/fiscal_document_nfse_demo.xml +0 -4
- odoo/addons/l10n_br_fiscal/demo/fiscal_operation_demo.xml +2 -2
- odoo/addons/l10n_br_fiscal/i18n/l10n_br_fiscal.pot +78 -54
- odoo/addons/l10n_br_fiscal/i18n/pt_BR.po +91 -60
- odoo/addons/l10n_br_fiscal/migrations/17.0.2.0.0/pre-migration.py +25 -0
- odoo/addons/l10n_br_fiscal/migrations/17.0.3.0.0/pre-migration.py +30 -0
- odoo/addons/l10n_br_fiscal/models/comment.py +2 -2
- odoo/addons/l10n_br_fiscal/models/document.py +31 -6
- odoo/addons/l10n_br_fiscal/models/document_line.py +49 -2
- odoo/addons/l10n_br_fiscal/models/document_line_mixin.py +63 -19
- odoo/addons/l10n_br_fiscal/models/document_line_mixin_methods.py +99 -68
- odoo/addons/l10n_br_fiscal/models/document_mixin.py +3 -12
- odoo/addons/l10n_br_fiscal/models/document_mixin_methods.py +33 -169
- odoo/addons/l10n_br_fiscal/models/document_related.py +1 -1
- odoo/addons/l10n_br_fiscal/models/document_serie.py +33 -0
- odoo/addons/l10n_br_fiscal/models/ibpt.py +1 -1
- odoo/addons/l10n_br_fiscal/models/icms_regulation.py +1 -1
- odoo/addons/l10n_br_fiscal/models/invalidate_number.py +4 -5
- odoo/addons/l10n_br_fiscal/models/operation_dashboard.py +1 -1
- odoo/addons/l10n_br_fiscal/models/product_template.py +1 -1
- odoo/addons/l10n_br_fiscal/models/res_partner.py +4 -0
- odoo/addons/l10n_br_fiscal/models/tax.py +7 -3
- odoo/addons/l10n_br_fiscal/models/tax_pis_cofins_base.py +1 -1
- odoo/addons/l10n_br_fiscal/models/tax_pis_cofins_credit.py +1 -1
- odoo/addons/l10n_br_fiscal/security/fiscal_security.xml +6 -16
- odoo/addons/l10n_br_fiscal/security/ir.model.access.csv +1 -2
- 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_document_edition.py +138 -0
- odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_generic.py +3 -13
- odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_nfse.py +0 -1
- odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_serie.py +60 -0
- odoo/addons/l10n_br_fiscal/tests/test_tax_benefit.py +0 -1
- odoo/addons/l10n_br_fiscal/views/document_line_mixin_view.xml +0 -1
- odoo/addons/l10n_br_fiscal/views/document_line_view.xml +6 -4
- odoo/addons/l10n_br_fiscal/views/document_view.xml +10 -14
- odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_menu.xml +0 -9
- odoo/addons/l10n_br_fiscal/views/operation_dashboard_view.xml +3 -3
- odoo/addons/l10n_br_fiscal/views/product_product_view.xml +1 -1
- odoo/addons/l10n_br_fiscal/views/product_template_view.xml +1 -1
- odoo/addons/l10n_br_fiscal/views/res_partner_view.xml +3 -0
- odoo/addons/l10n_br_fiscal/wizards/base_wizard_mixin.py +1 -1
- {odoo_addon_l10n_br_fiscal-17.0.1.0.0.13.dist-info → odoo_addon_l10n_br_fiscal-17.0.4.0.0.1.dist-info}/METADATA +2 -2
- {odoo_addon_l10n_br_fiscal-17.0.1.0.0.13.dist-info → odoo_addon_l10n_br_fiscal-17.0.4.0.0.1.dist-info}/RECORD +52 -49
- {odoo_addon_l10n_br_fiscal-17.0.1.0.0.13.dist-info → odoo_addon_l10n_br_fiscal-17.0.4.0.0.1.dist-info}/WHEEL +0 -0
- {odoo_addon_l10n_br_fiscal-17.0.1.0.0.13.dist-info → odoo_addon_l10n_br_fiscal-17.0.4.0.0.1.dist-info}/top_level.txt +0 -0
|
@@ -36,7 +36,6 @@ from ..constants.icms import (
|
|
|
36
36
|
ICMS_BASE_TYPE,
|
|
37
37
|
ICMS_BASE_TYPE_DEFAULT,
|
|
38
38
|
ICMS_ORIGIN,
|
|
39
|
-
ICMS_ORIGIN_DEFAULT,
|
|
40
39
|
ICMS_ST_BASE_TYPE,
|
|
41
40
|
ICMS_ST_BASE_TYPE_DEFAULT,
|
|
42
41
|
)
|
|
@@ -78,10 +77,6 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
78
77
|
_inherit = "l10n_br_fiscal.document.line.mixin.methods"
|
|
79
78
|
_description = "Document Fiscal Mixin"
|
|
80
79
|
|
|
81
|
-
@api.model
|
|
82
|
-
def _default_operation(self):
|
|
83
|
-
return False
|
|
84
|
-
|
|
85
80
|
@api.model
|
|
86
81
|
def _default_icmssn_range_id(self):
|
|
87
82
|
company = self.env.company
|
|
@@ -139,16 +134,31 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
139
134
|
|
|
140
135
|
partner_company_type = fields.Selection(related="partner_id.company_type")
|
|
141
136
|
|
|
142
|
-
uom_id = fields.Many2one(
|
|
137
|
+
uom_id = fields.Many2one(
|
|
138
|
+
comodel_name="uom.uom",
|
|
139
|
+
string="UOM",
|
|
140
|
+
)
|
|
143
141
|
|
|
144
142
|
quantity = fields.Float(
|
|
145
143
|
digits="Product Unit of Measure",
|
|
146
144
|
)
|
|
147
145
|
|
|
148
|
-
fiscal_type = fields.Selection(
|
|
146
|
+
fiscal_type = fields.Selection(
|
|
147
|
+
selection=PRODUCT_FISCAL_TYPE,
|
|
148
|
+
compute="_compute_product_fiscal_fields",
|
|
149
|
+
store=True,
|
|
150
|
+
readonly=False,
|
|
151
|
+
precompute=True,
|
|
152
|
+
)
|
|
149
153
|
|
|
150
154
|
ncm_id = fields.Many2one(
|
|
151
|
-
comodel_name="l10n_br_fiscal.ncm",
|
|
155
|
+
comodel_name="l10n_br_fiscal.ncm",
|
|
156
|
+
index=True,
|
|
157
|
+
string="NCM",
|
|
158
|
+
compute="_compute_product_fiscal_fields",
|
|
159
|
+
store=True,
|
|
160
|
+
readonly=False,
|
|
161
|
+
precompute=True,
|
|
152
162
|
)
|
|
153
163
|
|
|
154
164
|
nbm_id = fields.Many2one(
|
|
@@ -156,6 +166,10 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
156
166
|
index=True,
|
|
157
167
|
string="NBM",
|
|
158
168
|
domain="[('ncm_ids', '=', ncm_id)]",
|
|
169
|
+
compute="_compute_product_fiscal_fields",
|
|
170
|
+
store=True,
|
|
171
|
+
readonly=False,
|
|
172
|
+
precompute=True,
|
|
159
173
|
)
|
|
160
174
|
|
|
161
175
|
cest_id = fields.Many2one(
|
|
@@ -163,17 +177,26 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
163
177
|
index=True,
|
|
164
178
|
string="CEST",
|
|
165
179
|
domain="[('ncm_ids', '=', ncm_id)]",
|
|
180
|
+
compute="_compute_product_fiscal_fields",
|
|
181
|
+
store=True,
|
|
182
|
+
readonly=False,
|
|
183
|
+
precompute=True,
|
|
166
184
|
)
|
|
167
185
|
|
|
168
186
|
nbs_id = fields.Many2one(
|
|
169
|
-
comodel_name="l10n_br_fiscal.nbs",
|
|
187
|
+
comodel_name="l10n_br_fiscal.nbs",
|
|
188
|
+
index=True,
|
|
189
|
+
string="NBS",
|
|
190
|
+
compute="_compute_product_fiscal_fields",
|
|
191
|
+
store=True,
|
|
192
|
+
readonly=False,
|
|
193
|
+
precompute=True,
|
|
170
194
|
)
|
|
171
195
|
|
|
172
196
|
fiscal_operation_id = fields.Many2one(
|
|
173
197
|
comodel_name="l10n_br_fiscal.operation",
|
|
174
198
|
string="Operation",
|
|
175
199
|
domain=lambda self: self._operation_domain(),
|
|
176
|
-
default=_default_operation,
|
|
177
200
|
)
|
|
178
201
|
|
|
179
202
|
fiscal_operation_type = fields.Selection(
|
|
@@ -263,11 +286,11 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
263
286
|
compute="_compute_fiscal_amounts",
|
|
264
287
|
)
|
|
265
288
|
|
|
266
|
-
|
|
289
|
+
fiscal_amount_untaxed = fields.Monetary(
|
|
267
290
|
compute="_compute_fiscal_amounts",
|
|
268
291
|
)
|
|
269
292
|
|
|
270
|
-
|
|
293
|
+
fiscal_amount_tax = fields.Monetary(
|
|
271
294
|
compute="_compute_fiscal_amounts",
|
|
272
295
|
)
|
|
273
296
|
|
|
@@ -275,7 +298,7 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
275
298
|
compute="_compute_fiscal_amounts",
|
|
276
299
|
)
|
|
277
300
|
|
|
278
|
-
|
|
301
|
+
fiscal_amount_total = fields.Monetary(
|
|
279
302
|
compute="_compute_fiscal_amounts",
|
|
280
303
|
)
|
|
281
304
|
|
|
@@ -301,7 +324,12 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
301
324
|
amount_tax_withholding = fields.Monetary(string="Tax Withholding")
|
|
302
325
|
|
|
303
326
|
fiscal_genre_id = fields.Many2one(
|
|
304
|
-
comodel_name="l10n_br_fiscal.product.genre",
|
|
327
|
+
comodel_name="l10n_br_fiscal.product.genre",
|
|
328
|
+
string="Fiscal Product Genre",
|
|
329
|
+
compute="_compute_product_fiscal_fields",
|
|
330
|
+
store=True,
|
|
331
|
+
readonly=False,
|
|
332
|
+
precompute=True,
|
|
305
333
|
)
|
|
306
334
|
|
|
307
335
|
fiscal_genre_code = fields.Char(
|
|
@@ -312,10 +340,19 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
312
340
|
comodel_name="l10n_br_fiscal.service.type",
|
|
313
341
|
string="Service Type LC 166",
|
|
314
342
|
domain="[('internal_type', '=', 'normal')]",
|
|
343
|
+
compute="_compute_product_fiscal_fields",
|
|
344
|
+
store=True,
|
|
345
|
+
readonly=False,
|
|
346
|
+
precompute=True,
|
|
315
347
|
)
|
|
316
348
|
|
|
317
349
|
city_taxation_code_id = fields.Many2one(
|
|
318
|
-
comodel_name="l10n_br_fiscal.city.taxation.code",
|
|
350
|
+
comodel_name="l10n_br_fiscal.city.taxation.code",
|
|
351
|
+
string="City Taxation Code",
|
|
352
|
+
compute="_compute_product_fiscal_fields",
|
|
353
|
+
store=True,
|
|
354
|
+
readonly=False,
|
|
355
|
+
precompute=True,
|
|
319
356
|
)
|
|
320
357
|
|
|
321
358
|
partner_order = fields.Char(string="Partner Order (xPed)", size=15)
|
|
@@ -336,6 +373,10 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
336
373
|
issqn_fg_city_id = fields.Many2one(
|
|
337
374
|
comodel_name="res.city",
|
|
338
375
|
string="ISSQN City",
|
|
376
|
+
compute="_compute_product_fiscal_fields",
|
|
377
|
+
store=True,
|
|
378
|
+
readonly=False,
|
|
379
|
+
precompute=True,
|
|
339
380
|
)
|
|
340
381
|
|
|
341
382
|
# vDeducao
|
|
@@ -492,7 +533,12 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
492
533
|
)
|
|
493
534
|
|
|
494
535
|
icms_origin = fields.Selection(
|
|
495
|
-
selection=ICMS_ORIGIN,
|
|
536
|
+
selection=ICMS_ORIGIN,
|
|
537
|
+
string="ICMS Origin",
|
|
538
|
+
compute="_compute_product_fiscal_fields",
|
|
539
|
+
store=True,
|
|
540
|
+
readonly=False,
|
|
541
|
+
precompute=True,
|
|
496
542
|
)
|
|
497
543
|
|
|
498
544
|
# vBC - Valor da base de cálculo do ICMS
|
|
@@ -1625,14 +1671,12 @@ class FiscalDocumentLineMixin(models.AbstractModel):
|
|
|
1625
1671
|
comodel_name="l10n_br_fiscal.comment",
|
|
1626
1672
|
string="Comments",
|
|
1627
1673
|
domain=[("object", "=", FISCAL_COMMENT_LINE)],
|
|
1628
|
-
compute="
|
|
1674
|
+
compute="_compute_comment_ids",
|
|
1629
1675
|
store=True,
|
|
1630
1676
|
precompute=True,
|
|
1631
1677
|
readonly=False,
|
|
1632
1678
|
)
|
|
1633
1679
|
|
|
1634
|
-
additional_data = fields.Text()
|
|
1635
|
-
|
|
1636
1680
|
manual_additional_data = fields.Text(
|
|
1637
1681
|
help="Additional data manually entered by user"
|
|
1638
1682
|
)
|
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
from copy import deepcopy
|
|
5
5
|
|
|
6
6
|
from lxml import etree
|
|
7
|
+
from lxml.builder import E
|
|
7
8
|
|
|
8
9
|
from odoo import Command, api, models
|
|
9
10
|
|
|
10
|
-
from ..constants.fiscal import CFOP_DESTINATION_EXPORT, FISCAL_IN
|
|
11
|
-
from ..constants.icms import
|
|
11
|
+
from ..constants.fiscal import CFOP_DESTINATION_EXPORT, FISCAL_IN, TAX_DOMAIN_ICMS
|
|
12
|
+
from ..constants.icms import (
|
|
13
|
+
ICMS_BASE_TYPE_DEFAULT,
|
|
14
|
+
ICMS_ORIGIN_DEFAULT,
|
|
15
|
+
ICMS_ST_BASE_TYPE_DEFAULT,
|
|
16
|
+
)
|
|
12
17
|
|
|
13
18
|
FISCAL_TAX_ID_FIELDS = [
|
|
14
19
|
"cofins_tax_id",
|
|
@@ -81,6 +86,23 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
|
|
|
81
86
|
Inject common fiscal fields into view placeholder elements.
|
|
82
87
|
Used for invoice line, sale order line, purchase order line...
|
|
83
88
|
"""
|
|
89
|
+
|
|
90
|
+
# the list of computed fields we will add to the view when missing
|
|
91
|
+
missing_line_fields = set(
|
|
92
|
+
[
|
|
93
|
+
fname
|
|
94
|
+
for fname, _field in filter(
|
|
95
|
+
lambda item: item[1].compute
|
|
96
|
+
in (
|
|
97
|
+
"_compute_tax_fields",
|
|
98
|
+
"_compute_fiscal_tax_ids",
|
|
99
|
+
"_compute_product_fiscal_fields",
|
|
100
|
+
),
|
|
101
|
+
self.env["l10n_br_fiscal.document.line.mixin"]._fields.items(),
|
|
102
|
+
)
|
|
103
|
+
]
|
|
104
|
+
)
|
|
105
|
+
|
|
84
106
|
fiscal_view = self.env.ref(
|
|
85
107
|
"l10n_br_fiscal.document_fiscal_line_mixin_form"
|
|
86
108
|
).sudo()
|
|
@@ -129,13 +151,19 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
|
|
|
129
151
|
e.attrib["name"] for e in target_node if e.tag == "field"
|
|
130
152
|
]
|
|
131
153
|
for fiscal_node in fiscal_nodes:
|
|
154
|
+
if fiscal_node.attrib["name"] in missing_line_fields:
|
|
155
|
+
missing_line_fields.remove(fiscal_node.attrib["name"])
|
|
132
156
|
if fiscal_node.attrib["name"] in existing_fields:
|
|
133
157
|
continue
|
|
134
158
|
field = deepcopy(fiscal_node)
|
|
135
159
|
if not field.attrib.get("optional"):
|
|
136
|
-
field.attrib["invisible"] = "0"
|
|
137
160
|
field.attrib["optional"] = "hide"
|
|
138
161
|
target_node.append(field)
|
|
162
|
+
for fname in missing_line_fields:
|
|
163
|
+
if fname not in existing_fields:
|
|
164
|
+
target_node.append(
|
|
165
|
+
E.field(name=fname, string=fname, optional="hide")
|
|
166
|
+
)
|
|
139
167
|
return doc
|
|
140
168
|
|
|
141
169
|
@api.model
|
|
@@ -171,11 +199,11 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
|
|
|
171
199
|
# Total value of products or services
|
|
172
200
|
record.price_gross = round_curr.round(record.price_unit * record.quantity)
|
|
173
201
|
record.amount_fiscal = record.price_gross - record.discount_value
|
|
174
|
-
record.
|
|
202
|
+
record.fiscal_amount_tax = record.amount_tax_not_included
|
|
175
203
|
|
|
176
204
|
add_to_amount = sum(record[a] for a in record._add_fields_to_amount())
|
|
177
205
|
rm_to_amount = sum(record[r] for r in record._rm_fields_to_amount())
|
|
178
|
-
record.
|
|
206
|
+
record.fiscal_amount_untaxed = (
|
|
179
207
|
record.price_gross
|
|
180
208
|
- record.discount_value
|
|
181
209
|
+ add_to_amount
|
|
@@ -183,13 +211,17 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
|
|
|
183
211
|
)
|
|
184
212
|
|
|
185
213
|
# Valor do documento (NF)
|
|
186
|
-
record.
|
|
214
|
+
record.fiscal_amount_total = (
|
|
215
|
+
record.fiscal_amount_untaxed + record.fiscal_amount_tax
|
|
216
|
+
)
|
|
187
217
|
|
|
188
218
|
# Valor Liquido (TOTAL + IMPOSTOS - RETENÇÕES)
|
|
189
|
-
record.amount_taxed =
|
|
219
|
+
record.amount_taxed = (
|
|
220
|
+
record.fiscal_amount_total - record.amount_tax_withholding
|
|
221
|
+
)
|
|
190
222
|
|
|
191
223
|
# Valor do documento (NF) - RETENÇÕES
|
|
192
|
-
record.
|
|
224
|
+
record.fiscal_amount_total = record.amount_taxed
|
|
193
225
|
|
|
194
226
|
# Valor financeiro
|
|
195
227
|
if (
|
|
@@ -305,11 +337,16 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
|
|
|
305
337
|
for tax in mapping_result["taxes"].values():
|
|
306
338
|
taxes |= tax
|
|
307
339
|
line.fiscal_tax_ids = taxes
|
|
308
|
-
line.comment_ids = line.fiscal_operation_line_id.comment_ids
|
|
309
|
-
|
|
310
340
|
else:
|
|
311
341
|
line.fiscal_tax_ids = [Command.clear()]
|
|
312
342
|
|
|
343
|
+
@api.depends("fiscal_operation_line_id")
|
|
344
|
+
def _compute_comment_ids(self):
|
|
345
|
+
for line in self:
|
|
346
|
+
line.comment_ids = [
|
|
347
|
+
Command.set(line.fiscal_operation_line_id.comment_ids.ids)
|
|
348
|
+
]
|
|
349
|
+
|
|
313
350
|
@api.model
|
|
314
351
|
def _build_null_mask_dict(self) -> dict:
|
|
315
352
|
"""
|
|
@@ -454,21 +491,6 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
|
|
|
454
491
|
"cost_price": line.product_id.standard_price,
|
|
455
492
|
}.get(line.fiscal_operation_id.default_price_unit, 0)
|
|
456
493
|
|
|
457
|
-
def __document_comment_vals(self):
|
|
458
|
-
self.ensure_one()
|
|
459
|
-
return {
|
|
460
|
-
"user": self.env.user,
|
|
461
|
-
"ctx": self._context,
|
|
462
|
-
"doc": self.document_id if hasattr(self, "document_id") else None,
|
|
463
|
-
"item": self,
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
def _document_comment(self):
|
|
467
|
-
for d in self:
|
|
468
|
-
d.additional_data = d.comment_ids.compute_message(
|
|
469
|
-
d.__document_comment_vals(), d.manual_additional_data
|
|
470
|
-
)
|
|
471
|
-
|
|
472
494
|
def _get_fiscal_partner(self):
|
|
473
495
|
"""
|
|
474
496
|
Meant to be overriden when the l10n_br_fiscal.document partner_id should not
|
|
@@ -480,48 +502,50 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
|
|
|
480
502
|
self.ensure_one()
|
|
481
503
|
return self.partner_id
|
|
482
504
|
|
|
483
|
-
@api.
|
|
484
|
-
def
|
|
485
|
-
if
|
|
505
|
+
@api.depends("product_id")
|
|
506
|
+
def _compute_product_fiscal_fields(self):
|
|
507
|
+
if self._context.get("skip_compute_product_fiscal_fields"):
|
|
486
508
|
return
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
509
|
+
for line in self:
|
|
510
|
+
if not line.product_id:
|
|
511
|
+
# reset to default values:
|
|
512
|
+
line.fiscal_type = False
|
|
513
|
+
line.ncm_id = False
|
|
514
|
+
line.nbm_id = False
|
|
515
|
+
line.tax_icms_or_issqn = TAX_DOMAIN_ICMS
|
|
516
|
+
line.icms_origin = ICMS_ORIGIN_DEFAULT
|
|
517
|
+
line.cest_id = False
|
|
518
|
+
line.nbs_id = False
|
|
519
|
+
line.fiscal_genre_id = False
|
|
520
|
+
line.service_type_id = False
|
|
521
|
+
line.city_taxation_code_id = False
|
|
522
|
+
line.issqn_fg_city_id = False
|
|
523
|
+
continue
|
|
524
|
+
|
|
525
|
+
product = line.product_id
|
|
526
|
+
line.fiscal_type = product.fiscal_type
|
|
527
|
+
line.ncm_id = product.ncm_id
|
|
528
|
+
line.nbm_id = product.nbm_id
|
|
529
|
+
line.tax_icms_or_issqn = product.tax_icms_or_issqn
|
|
530
|
+
line.icms_origin = product.icms_origin
|
|
531
|
+
line.cest_id = product.cest_id
|
|
532
|
+
line.nbs_id = product.nbs_id
|
|
533
|
+
line.fiscal_genre_id = product.fiscal_genre_id
|
|
534
|
+
line.service_type_id = product.service_type_id
|
|
535
|
+
if product.city_taxation_code_ids and line.company_id:
|
|
536
|
+
city = product.city_taxation_code_ids.filtered(
|
|
537
|
+
lambda r, current_line=line: r.city_id
|
|
538
|
+
== current_line.company_id.city_id
|
|
504
539
|
)
|
|
505
|
-
if
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
self.tax_icms_or_issqn = False
|
|
515
|
-
self.icms_origin = False
|
|
516
|
-
self.cest_id = False
|
|
517
|
-
self.nbs_id = False
|
|
518
|
-
self.fiscal_genre_id = False
|
|
519
|
-
self.service_type_id = False
|
|
520
|
-
self.city_taxation_code_id = False
|
|
521
|
-
self.uot_id = False
|
|
522
|
-
|
|
523
|
-
self._compute_price_unit_fiscal()
|
|
524
|
-
self._onchange_fiscal_operation_id()
|
|
540
|
+
if city:
|
|
541
|
+
line.city_taxation_code_id = city
|
|
542
|
+
line.issqn_fg_city_id = line.company_id.city_id
|
|
543
|
+
else:
|
|
544
|
+
line.city_taxation_code_id = False
|
|
545
|
+
line.issqn_fg_city_id = False
|
|
546
|
+
else:
|
|
547
|
+
line.city_taxation_code_id = False
|
|
548
|
+
line.issqn_fg_city_id = False
|
|
525
549
|
|
|
526
550
|
def _prepare_fields_issqn(self, tax_dict):
|
|
527
551
|
self.ensure_one()
|
|
@@ -777,11 +801,18 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
|
|
|
777
801
|
)
|
|
778
802
|
line.fiscal_tax_ids = fiscal_taxes + taxes
|
|
779
803
|
|
|
780
|
-
@api.depends("uom_id")
|
|
804
|
+
@api.depends("product_id", "uom_id")
|
|
781
805
|
def _compute_uot_id(self):
|
|
782
806
|
for line in self:
|
|
783
|
-
if
|
|
784
|
-
line.uot_id = line.uom_id
|
|
807
|
+
if line.uom_id:
|
|
808
|
+
line.uot_id = line.uom_id.id
|
|
809
|
+
elif line.product_id:
|
|
810
|
+
if line.product_id.uot_id:
|
|
811
|
+
line.uot_id = line.product_id.uot_id.id
|
|
812
|
+
else:
|
|
813
|
+
line.uot_id = line.product_id.uom_id.id
|
|
814
|
+
else:
|
|
815
|
+
line.uot_id = False
|
|
785
816
|
|
|
786
817
|
@api.onchange("price_unit")
|
|
787
818
|
def _onchange_price_unit_fiscal(self):
|
|
@@ -48,10 +48,6 @@ class FiscalDocumentMixin(models.AbstractModel):
|
|
|
48
48
|
def _date_server_format(self):
|
|
49
49
|
return fields.Datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
|
50
50
|
|
|
51
|
-
@api.model
|
|
52
|
-
def _default_operation(self):
|
|
53
|
-
return False
|
|
54
|
-
|
|
55
51
|
@api.model
|
|
56
52
|
def _operation_domain(self):
|
|
57
53
|
domain = (
|
|
@@ -66,7 +62,6 @@ class FiscalDocumentMixin(models.AbstractModel):
|
|
|
66
62
|
comodel_name="l10n_br_fiscal.operation",
|
|
67
63
|
string="Operation",
|
|
68
64
|
domain=lambda self: self._operation_domain(),
|
|
69
|
-
default=_default_operation,
|
|
70
65
|
)
|
|
71
66
|
|
|
72
67
|
operation_name = fields.Char(
|
|
@@ -105,14 +100,10 @@ class FiscalDocumentMixin(models.AbstractModel):
|
|
|
105
100
|
store=True,
|
|
106
101
|
)
|
|
107
102
|
|
|
108
|
-
fiscal_additional_data = fields.Text()
|
|
109
|
-
|
|
110
103
|
manual_fiscal_additional_data = fields.Text(
|
|
111
104
|
help="Fiscal Additional data manually entered by user",
|
|
112
105
|
)
|
|
113
106
|
|
|
114
|
-
customer_additional_data = fields.Text()
|
|
115
|
-
|
|
116
107
|
manual_customer_additional_data = fields.Text(
|
|
117
108
|
help="Customer Additional data manually entered by user",
|
|
118
109
|
)
|
|
@@ -135,7 +126,7 @@ class FiscalDocumentMixin(models.AbstractModel):
|
|
|
135
126
|
help="Amount without discount.",
|
|
136
127
|
)
|
|
137
128
|
|
|
138
|
-
|
|
129
|
+
fiscal_amount_untaxed = fields.Monetary(
|
|
139
130
|
compute="_compute_fiscal_amount",
|
|
140
131
|
store=True,
|
|
141
132
|
)
|
|
@@ -403,12 +394,12 @@ class FiscalDocumentMixin(models.AbstractModel):
|
|
|
403
394
|
store=True,
|
|
404
395
|
)
|
|
405
396
|
|
|
406
|
-
|
|
397
|
+
fiscal_amount_tax = fields.Monetary(
|
|
407
398
|
compute="_compute_fiscal_amount",
|
|
408
399
|
store=True,
|
|
409
400
|
)
|
|
410
401
|
|
|
411
|
-
|
|
402
|
+
fiscal_amount_total = fields.Monetary(
|
|
412
403
|
compute="_compute_fiscal_amount",
|
|
413
404
|
store=True,
|
|
414
405
|
)
|