odoo-addon-l10n-br-fiscal 16.0.2.17.0__py3-none-any.whl → 16.0.19.4.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/README.rst +11 -4
- odoo/addons/l10n_br_fiscal/__manifest__.py +20 -12
- odoo/addons/l10n_br_fiscal/constants/fiscal.py +64 -18
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.cest.csv +1043 -983
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.cfop.csv +620 -620
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.cst.csv +58 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.document.type.csv +1 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.legal.nature.csv +82 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.nbs.csv +791 -764
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.operation.indicator.csv +27 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.partner.profile.csv +11 -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 +32 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal.tax.group.csv +3 -0
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal_icms_tax_definition_data.xml +340 -352
- odoo/addons/l10n_br_fiscal/data/operation_data.xml +1 -1
- odoo/addons/l10n_br_fiscal/data/simplified_tax_data.xml +5 -5
- odoo/addons/l10n_br_fiscal/data/uom.alias.csv +25 -0
- odoo/addons/l10n_br_fiscal/data/uom_data.xml +104 -33
- odoo/addons/l10n_br_fiscal/demo/__init__.py +21 -15
- odoo/addons/l10n_br_fiscal/demo/company_demo.xml +6 -0
- odoo/addons/l10n_br_fiscal/demo/fiscal_document_demo.xml +3 -377
- odoo/addons/l10n_br_fiscal/demo/fiscal_document_nfse_demo.xml +0 -12
- odoo/addons/l10n_br_fiscal/demo/fiscal_operation_demo.xml +2 -2
- odoo/addons/l10n_br_fiscal/demo/icms_tax_definition_demo.xml +5 -2
- odoo/addons/l10n_br_fiscal/demo/res_users_demo.xml +2 -2
- odoo/addons/l10n_br_fiscal/i18n/l10n_br_fiscal.pot +1161 -804
- odoo/addons/l10n_br_fiscal/i18n/pt_BR.po +22 -22
- odoo/addons/l10n_br_fiscal/migrations/16.0.13.0.0/pre-migration.py +25 -0
- odoo/addons/l10n_br_fiscal/migrations/16.0.14.0.0/pre-migration.py +30 -0
- odoo/addons/l10n_br_fiscal/migrations/16.0.14.0.5/pre-migration.py +15 -0
- odoo/addons/l10n_br_fiscal/migrations/16.0.4.0.0/pre-migration.py +220 -0
- odoo/addons/l10n_br_fiscal/migrations/16.0.5.0.0/pre-migration.py +33 -0
- odoo/addons/l10n_br_fiscal/migrations/16.0.5.2.0/pre-migration.py +21 -0
- odoo/addons/l10n_br_fiscal/models/__init__.py +3 -8
- odoo/addons/l10n_br_fiscal/models/cest.py +0 -8
- odoo/addons/l10n_br_fiscal/models/cfop.py +91 -0
- odoo/addons/l10n_br_fiscal/models/city_taxation_code.py +1 -3
- odoo/addons/l10n_br_fiscal/models/comment.py +2 -2
- odoo/addons/l10n_br_fiscal/models/cst.py +0 -1
- odoo/addons/l10n_br_fiscal/models/data_abstract.py +26 -0
- odoo/addons/l10n_br_fiscal/models/data_ncm_nbs_abstract.py +1 -1
- odoo/addons/l10n_br_fiscal/models/document.py +131 -222
- odoo/addons/l10n_br_fiscal/models/document_line.py +82 -5
- odoo/addons/l10n_br_fiscal/models/document_line_mixin.py +1952 -138
- odoo/addons/l10n_br_fiscal/models/document_mixin.py +741 -6
- odoo/addons/l10n_br_fiscal/models/document_related.py +12 -9
- odoo/addons/l10n_br_fiscal/models/document_serie.py +33 -0
- odoo/addons/l10n_br_fiscal/models/document_type.py +0 -6
- odoo/addons/l10n_br_fiscal/models/ibpt.py +1 -1
- odoo/addons/l10n_br_fiscal/models/icms_regulation.py +2 -2
- odoo/addons/l10n_br_fiscal/models/invalidate_number.py +4 -5
- odoo/addons/l10n_br_fiscal/models/legal_nature.py +20 -0
- odoo/addons/l10n_br_fiscal/models/nbm.py +0 -8
- odoo/addons/l10n_br_fiscal/models/ncm.py +0 -12
- odoo/addons/l10n_br_fiscal/models/operation.py +49 -15
- odoo/addons/l10n_br_fiscal/models/operation_dashboard.py +3 -2
- odoo/addons/l10n_br_fiscal/models/operation_indicator.py +58 -0
- odoo/addons/l10n_br_fiscal/models/operation_line.py +75 -6
- odoo/addons/l10n_br_fiscal/models/partner_profile.py +6 -0
- odoo/addons/l10n_br_fiscal/models/product_mixin.py +24 -21
- odoo/addons/l10n_br_fiscal/models/product_template.py +23 -13
- odoo/addons/l10n_br_fiscal/models/res_company.py +31 -9
- odoo/addons/l10n_br_fiscal/models/res_partner.py +38 -6
- odoo/addons/l10n_br_fiscal/models/simplified_tax.py +0 -3
- odoo/addons/l10n_br_fiscal/models/simplified_tax_range.py +8 -0
- odoo/addons/l10n_br_fiscal/models/tax.py +144 -55
- odoo/addons/l10n_br_fiscal/models/tax_classification.py +81 -0
- odoo/addons/l10n_br_fiscal/models/tax_definition.py +72 -23
- odoo/addons/l10n_br_fiscal/models/tax_pis_cofins.py +0 -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/models/uom_uom.py +15 -30
- odoo/addons/l10n_br_fiscal/security/fiscal_security.xml +11 -27
- odoo/addons/l10n_br_fiscal/security/ir.model.access.csv +11 -10
- odoo/addons/l10n_br_fiscal/static/description/index.html +27 -21
- odoo/addons/l10n_br_fiscal/static/src/js/list_renderer_with_button.esm.js +38 -0
- odoo/addons/l10n_br_fiscal/tests/__init__.py +3 -2
- odoo/addons/l10n_br_fiscal/tests/test_document_edition.py +308 -0
- odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_generic.py +23 -129
- odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_nfse.py +5 -15
- odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_serie.py +60 -0
- odoo/addons/l10n_br_fiscal/tests/test_ibpt.py +4 -3
- odoo/addons/l10n_br_fiscal/tests/test_icms_regulation.py +2 -2
- odoo/addons/l10n_br_fiscal/tests/test_ncm.py +4 -1
- odoo/addons/l10n_br_fiscal/tests/test_tax_benefit.py +17 -22
- odoo/addons/l10n_br_fiscal/tests/test_tax_classification.py +110 -0
- odoo/addons/l10n_br_fiscal/tools.py +1 -1
- odoo/addons/l10n_br_fiscal/views/cest_view.xml +2 -4
- odoo/addons/l10n_br_fiscal/views/cfop_view.xml +25 -5
- odoo/addons/l10n_br_fiscal/views/city_taxation_code.xml +1 -4
- odoo/addons/l10n_br_fiscal/views/cnae_view.xml +2 -4
- odoo/addons/l10n_br_fiscal/views/comment_view.xml +2 -4
- odoo/addons/l10n_br_fiscal/views/cst_view.xml +6 -8
- odoo/addons/l10n_br_fiscal/views/{document_fiscal_line_mixin_view.xml → document_line_mixin_view.xml} +525 -385
- odoo/addons/l10n_br_fiscal/views/document_line_view.xml +101 -82
- odoo/addons/l10n_br_fiscal/views/document_related_view.xml +44 -46
- odoo/addons/l10n_br_fiscal/views/document_serie_view.xml +2 -6
- odoo/addons/l10n_br_fiscal/views/document_type_view.xml +0 -8
- odoo/addons/l10n_br_fiscal/views/document_view.xml +303 -370
- odoo/addons/l10n_br_fiscal/views/icms_regulation_view.xml +14 -16
- odoo/addons/l10n_br_fiscal/views/icms_relief_view.xml +8 -10
- odoo/addons/l10n_br_fiscal/views/invalidate_number_view.xml +46 -48
- odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_action.xml +166 -280
- odoo/addons/l10n_br_fiscal/views/l10n_br_fiscal_menu.xml +25 -99
- odoo/addons/l10n_br_fiscal/views/legal_nature_view.xml +40 -0
- odoo/addons/l10n_br_fiscal/views/nbm_view.xml +5 -6
- odoo/addons/l10n_br_fiscal/views/nbs_view.xml +5 -6
- odoo/addons/l10n_br_fiscal/views/ncm_view.xml +12 -15
- odoo/addons/l10n_br_fiscal/views/operation_dashboard_view.xml +13 -12
- odoo/addons/l10n_br_fiscal/views/operation_indicator_view.xml +75 -0
- odoo/addons/l10n_br_fiscal/views/operation_line_view.xml +22 -21
- odoo/addons/l10n_br_fiscal/views/operation_view.xml +4 -19
- odoo/addons/l10n_br_fiscal/views/partner_profile_view.xml +3 -6
- odoo/addons/l10n_br_fiscal/views/product_genre_view.xml +7 -9
- odoo/addons/l10n_br_fiscal/views/product_product_view.xml +37 -14
- odoo/addons/l10n_br_fiscal/views/product_template_view.xml +34 -14
- odoo/addons/l10n_br_fiscal/views/res_company_view.xml +55 -52
- odoo/addons/l10n_br_fiscal/views/res_config_settings_view.xml +23 -28
- odoo/addons/l10n_br_fiscal/views/res_partner_view.xml +22 -2
- odoo/addons/l10n_br_fiscal/views/service_type_view.xml +7 -8
- odoo/addons/l10n_br_fiscal/views/simplified_tax_range_view.xml +0 -2
- odoo/addons/l10n_br_fiscal/views/simplified_tax_view.xml +0 -2
- odoo/addons/l10n_br_fiscal/views/tax_classification.xml +110 -0
- odoo/addons/l10n_br_fiscal/views/tax_definition_view.xml +157 -129
- odoo/addons/l10n_br_fiscal/views/tax_estimate_view.xml +0 -2
- odoo/addons/l10n_br_fiscal/views/tax_group_view.xml +3 -6
- odoo/addons/l10n_br_fiscal/views/tax_ipi_control_seal_view.xml +0 -2
- odoo/addons/l10n_br_fiscal/views/tax_ipi_guideline_class_view.xml +0 -2
- odoo/addons/l10n_br_fiscal/views/tax_ipi_guideline_view.xml +2 -4
- odoo/addons/l10n_br_fiscal/views/tax_pis_cofins_base_view.xml +2 -4
- odoo/addons/l10n_br_fiscal/views/tax_pis_cofins_credit_view.xml +2 -4
- odoo/addons/l10n_br_fiscal/views/tax_pis_cofins_view.xml +5 -7
- odoo/addons/l10n_br_fiscal/views/tax_view.xml +5 -7
- odoo/addons/l10n_br_fiscal/views/uom_uom.xml +24 -17
- odoo/addons/l10n_br_fiscal/wizards/__init__.py +1 -0
- odoo/addons/l10n_br_fiscal/wizards/base_wizard_mixin.py +1 -1
- odoo/addons/l10n_br_fiscal/wizards/document_import_wizard_mixin.py +129 -0
- odoo/addons/l10n_br_fiscal/wizards/document_import_wizard_mixin.xml +41 -0
- {odoo_addon_l10n_br_fiscal-16.0.2.17.0.dist-info → odoo_addon_l10n_br_fiscal-16.0.19.4.0.dist-info}/METADATA +15 -6
- odoo_addon_l10n_br_fiscal-16.0.19.4.0.dist-info/RECORD +210 -0
- {odoo_addon_l10n_br_fiscal-16.0.2.17.0.dist-info → odoo_addon_l10n_br_fiscal-16.0.19.4.0.dist-info}/WHEEL +1 -1
- odoo/addons/l10n_br_fiscal/data/l10n_br_fiscal_email_template.xml +0 -68
- odoo/addons/l10n_br_fiscal/data/partner_profile_data.xml +0 -96
- odoo/addons/l10n_br_fiscal/data/uom_alternative_data.xml +0 -58
- odoo/addons/l10n_br_fiscal/demo/l10n_br_fiscal_document_email.xml +0 -54
- odoo/addons/l10n_br_fiscal/demo/subsequent_operation_demo.xml +0 -10
- odoo/addons/l10n_br_fiscal/models/document_email.py +0 -74
- odoo/addons/l10n_br_fiscal/models/document_line_mixin_methods.py +0 -913
- odoo/addons/l10n_br_fiscal/models/document_mixin_fields.py +0 -473
- odoo/addons/l10n_br_fiscal/models/document_mixin_methods.py +0 -269
- odoo/addons/l10n_br_fiscal/models/document_move_mixin.py +0 -261
- odoo/addons/l10n_br_fiscal/models/subsequent_document.py +0 -203
- odoo/addons/l10n_br_fiscal/models/subsequent_operation.py +0 -54
- odoo/addons/l10n_br_fiscal/models/uom_uom_alternative.py +0 -22
- odoo/addons/l10n_br_fiscal/tests/test_subsequent_operation.py +0 -71
- odoo/addons/l10n_br_fiscal/tests/test_uom_uom.py +0 -22
- odoo/addons/l10n_br_fiscal/views/document_email_view.xml +0 -48
- odoo/addons/l10n_br_fiscal/views/subsequent_document_view.xml +0 -43
- odoo/addons/l10n_br_fiscal/views/subsequent_operation_view.xml +0 -21
- odoo_addon_l10n_br_fiscal-16.0.2.17.0.dist-info/RECORD +0 -205
- {odoo_addon_l10n_br_fiscal-16.0.2.17.0.dist-info → odoo_addon_l10n_br_fiscal-16.0.19.4.0.dist-info}/top_level.txt +0 -0
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
# Copyright (C) 2019 Renato Lima - Akretion <renato.lima@akretion.com.br>
|
|
2
|
-
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
|
3
|
-
|
|
4
|
-
from odoo import api, models
|
|
5
|
-
|
|
6
|
-
from ..constants.fiscal import COMMENT_TYPE_COMMERCIAL, COMMENT_TYPE_FISCAL
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class FiscalDocumentMixinMethods(models.AbstractModel):
|
|
10
|
-
_name = "l10n_br_fiscal.document.mixin.methods"
|
|
11
|
-
_description = "Fiscal Document Mixin Methods"
|
|
12
|
-
|
|
13
|
-
def _prepare_br_fiscal_dict(self, default=False):
|
|
14
|
-
self.ensure_one()
|
|
15
|
-
fields = self.env["l10n_br_fiscal.document.mixin"]._fields.keys()
|
|
16
|
-
|
|
17
|
-
# we now read the record fiscal fields except the m2m tax:
|
|
18
|
-
vals = self._convert_to_write(self.read(fields)[0])
|
|
19
|
-
|
|
20
|
-
# remove id field to avoid conflicts
|
|
21
|
-
vals.pop("id", None)
|
|
22
|
-
|
|
23
|
-
if default: # in case you want to use new rather than write later
|
|
24
|
-
return {f"default_{k}": vals[k] for k in vals.keys()}
|
|
25
|
-
return vals
|
|
26
|
-
|
|
27
|
-
def _get_amount_lines(self):
|
|
28
|
-
"""Get object lines instaces used to compute fields"""
|
|
29
|
-
return self.mapped("fiscal_line_ids")
|
|
30
|
-
|
|
31
|
-
def _get_product_amount_lines(self):
|
|
32
|
-
"""Get object lines instaces used to compute fields"""
|
|
33
|
-
fiscal_line_ids = self._get_amount_lines()
|
|
34
|
-
return fiscal_line_ids.filtered(lambda line: line.product_id.type != "service")
|
|
35
|
-
|
|
36
|
-
@api.model
|
|
37
|
-
def _get_amount_fields(self):
|
|
38
|
-
"""Get all fields with 'amount_' prefix"""
|
|
39
|
-
fields = self.env["l10n_br_fiscal.document.mixin"]._fields.keys()
|
|
40
|
-
amount_fields = [f for f in fields if f.startswith("amount_")]
|
|
41
|
-
return amount_fields
|
|
42
|
-
|
|
43
|
-
def _compute_fiscal_amount(self):
|
|
44
|
-
fields = self._get_amount_fields()
|
|
45
|
-
for doc in self:
|
|
46
|
-
values = {key: 0.0 for key in fields}
|
|
47
|
-
for line in doc._get_amount_lines():
|
|
48
|
-
for field in fields:
|
|
49
|
-
if field in line._fields.keys():
|
|
50
|
-
values[field] += line[field]
|
|
51
|
-
if field.replace("amount_", "") in line._fields.keys():
|
|
52
|
-
# FIXME this field creates an error in invoice form
|
|
53
|
-
if field == "amount_financial_discount_value":
|
|
54
|
-
values[
|
|
55
|
-
"amount_financial_discount_value"
|
|
56
|
-
] += 0 # line.financial_discount_value
|
|
57
|
-
else:
|
|
58
|
-
values[field] += line[field.replace("amount_", "")]
|
|
59
|
-
|
|
60
|
-
# Valores definidos pelo Total e não pela Linha
|
|
61
|
-
if (
|
|
62
|
-
doc.company_id.delivery_costs == "total"
|
|
63
|
-
or doc.force_compute_delivery_costs_by_total
|
|
64
|
-
):
|
|
65
|
-
values["amount_freight_value"] = doc.amount_freight_value
|
|
66
|
-
values["amount_insurance_value"] = doc.amount_insurance_value
|
|
67
|
-
values["amount_other_value"] = doc.amount_other_value
|
|
68
|
-
|
|
69
|
-
doc.update(values)
|
|
70
|
-
|
|
71
|
-
def __document_comment_vals(self):
|
|
72
|
-
return {
|
|
73
|
-
"user": self.env.user,
|
|
74
|
-
"ctx": self._context,
|
|
75
|
-
"doc": self,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
def _document_comment(self):
|
|
79
|
-
for d in self:
|
|
80
|
-
# Fiscal Comments
|
|
81
|
-
d.fiscal_additional_data = d.comment_ids.filtered(
|
|
82
|
-
lambda c: c.comment_type == COMMENT_TYPE_FISCAL
|
|
83
|
-
).compute_message(
|
|
84
|
-
d.__document_comment_vals(), d.manual_fiscal_additional_data
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
# Commercial Comments
|
|
88
|
-
d.customer_additional_data = d.comment_ids.filtered(
|
|
89
|
-
lambda c: c.comment_type == COMMENT_TYPE_COMMERCIAL
|
|
90
|
-
).compute_message(
|
|
91
|
-
d.__document_comment_vals(), d.manual_customer_additional_data
|
|
92
|
-
)
|
|
93
|
-
d.fiscal_line_ids._document_comment()
|
|
94
|
-
|
|
95
|
-
def _get_fiscal_partner(self):
|
|
96
|
-
"""
|
|
97
|
-
Meant to be overriden when the l10n_br_fiscal.document partner_id should not
|
|
98
|
-
be the same as the sale.order, purchase.order, account.move (...) partner_id.
|
|
99
|
-
|
|
100
|
-
(In the case of invoicing, the invoicing partner set by the user should
|
|
101
|
-
get priority over any invoicing contact returned by address_get.)
|
|
102
|
-
"""
|
|
103
|
-
self.ensure_one()
|
|
104
|
-
return self.partner_id
|
|
105
|
-
|
|
106
|
-
@api.onchange("partner_id")
|
|
107
|
-
def _onchange_partner_id_fiscal(self):
|
|
108
|
-
partner = self._get_fiscal_partner()
|
|
109
|
-
if partner:
|
|
110
|
-
self.ind_final = partner.ind_final
|
|
111
|
-
for line in self._get_amount_lines():
|
|
112
|
-
# reload fiscal data, operation line, cfop, taxes, etc.
|
|
113
|
-
line._onchange_fiscal_operation_id()
|
|
114
|
-
|
|
115
|
-
@api.onchange("fiscal_operation_id")
|
|
116
|
-
def _onchange_fiscal_operation_id(self):
|
|
117
|
-
if self.fiscal_operation_id:
|
|
118
|
-
self.operation_name = self.fiscal_operation_id.name
|
|
119
|
-
self.comment_ids = self.fiscal_operation_id.comment_ids
|
|
120
|
-
|
|
121
|
-
def _inverse_amount_freight(self):
|
|
122
|
-
for record in self.filtered(lambda doc: doc._get_product_amount_lines()):
|
|
123
|
-
if (
|
|
124
|
-
record.delivery_costs == "total"
|
|
125
|
-
or record.force_compute_delivery_costs_by_total
|
|
126
|
-
):
|
|
127
|
-
amount_freight_value = record.amount_freight_value
|
|
128
|
-
if all(record._get_product_amount_lines().mapped("freight_value")):
|
|
129
|
-
amount_freight_old = sum(
|
|
130
|
-
record._get_product_amount_lines().mapped("freight_value")
|
|
131
|
-
)
|
|
132
|
-
for line in record._get_product_amount_lines()[:-1]:
|
|
133
|
-
line.freight_value = amount_freight_value * (
|
|
134
|
-
line.freight_value / amount_freight_old
|
|
135
|
-
)
|
|
136
|
-
record._get_product_amount_lines()[-1].freight_value = (
|
|
137
|
-
amount_freight_value
|
|
138
|
-
- sum(
|
|
139
|
-
line.freight_value
|
|
140
|
-
for line in record._get_product_amount_lines()[:-1]
|
|
141
|
-
)
|
|
142
|
-
)
|
|
143
|
-
else:
|
|
144
|
-
amount_total = sum(
|
|
145
|
-
record._get_product_amount_lines().mapped("price_gross")
|
|
146
|
-
)
|
|
147
|
-
for line in record._get_product_amount_lines()[:-1]:
|
|
148
|
-
if line.price_gross and amount_total:
|
|
149
|
-
line.freight_value = amount_freight_value * (
|
|
150
|
-
line.price_gross / amount_total
|
|
151
|
-
)
|
|
152
|
-
record._get_product_amount_lines()[-1].freight_value = (
|
|
153
|
-
amount_freight_value
|
|
154
|
-
- sum(
|
|
155
|
-
line.freight_value
|
|
156
|
-
for line in record._get_product_amount_lines()[:-1]
|
|
157
|
-
)
|
|
158
|
-
)
|
|
159
|
-
for line in record._get_product_amount_lines():
|
|
160
|
-
line._onchange_fiscal_taxes()
|
|
161
|
-
record._fields["amount_total"].compute_value(record)
|
|
162
|
-
record.write(
|
|
163
|
-
{
|
|
164
|
-
name: value
|
|
165
|
-
for name, value in record._cache.items()
|
|
166
|
-
if record._fields[name].compute == "_amount_all"
|
|
167
|
-
and not record._fields[name].inverse
|
|
168
|
-
}
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
def _inverse_amount_insurance(self):
|
|
172
|
-
for record in self.filtered(lambda doc: doc._get_product_amount_lines()):
|
|
173
|
-
if (
|
|
174
|
-
record.delivery_costs == "total"
|
|
175
|
-
or record.force_compute_delivery_costs_by_total
|
|
176
|
-
):
|
|
177
|
-
amount_insurance_value = record.amount_insurance_value
|
|
178
|
-
if all(record._get_product_amount_lines().mapped("insurance_value")):
|
|
179
|
-
amount_insurance_old = sum(
|
|
180
|
-
record._get_product_amount_lines().mapped("insurance_value")
|
|
181
|
-
)
|
|
182
|
-
for line in record._get_product_amount_lines()[:-1]:
|
|
183
|
-
line.insurance_value = amount_insurance_value * (
|
|
184
|
-
line.insurance_value / amount_insurance_old
|
|
185
|
-
)
|
|
186
|
-
record._get_product_amount_lines()[-1].insurance_value = (
|
|
187
|
-
amount_insurance_value
|
|
188
|
-
- sum(
|
|
189
|
-
line.insurance_value
|
|
190
|
-
for line in record._get_product_amount_lines()[:-1]
|
|
191
|
-
)
|
|
192
|
-
)
|
|
193
|
-
else:
|
|
194
|
-
amount_total = sum(
|
|
195
|
-
record._get_product_amount_lines().mapped("price_gross")
|
|
196
|
-
)
|
|
197
|
-
for line in record._get_product_amount_lines()[:-1]:
|
|
198
|
-
if line.price_gross and amount_total:
|
|
199
|
-
line.insurance_value = amount_insurance_value * (
|
|
200
|
-
line.price_gross / amount_total
|
|
201
|
-
)
|
|
202
|
-
record._get_product_amount_lines()[-1].insurance_value = (
|
|
203
|
-
amount_insurance_value
|
|
204
|
-
- sum(
|
|
205
|
-
line.insurance_value
|
|
206
|
-
for line in record._get_product_amount_lines()[:-1]
|
|
207
|
-
)
|
|
208
|
-
)
|
|
209
|
-
for line in record._get_product_amount_lines():
|
|
210
|
-
line._onchange_fiscal_taxes()
|
|
211
|
-
record._fields["amount_total"].compute_value(record)
|
|
212
|
-
record.write(
|
|
213
|
-
{
|
|
214
|
-
name: value
|
|
215
|
-
for name, value in record._cache.items()
|
|
216
|
-
if record._fields[name].compute == "_amount_all"
|
|
217
|
-
and not record._fields[name].inverse
|
|
218
|
-
}
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
def _inverse_amount_other(self):
|
|
222
|
-
for record in self.filtered(lambda doc: doc._get_product_amount_lines()):
|
|
223
|
-
if (
|
|
224
|
-
record.delivery_costs == "total"
|
|
225
|
-
or record.force_compute_delivery_costs_by_total
|
|
226
|
-
):
|
|
227
|
-
amount_other_value = record.amount_other_value
|
|
228
|
-
if all(record._get_product_amount_lines().mapped("other_value")):
|
|
229
|
-
amount_other_old = sum(
|
|
230
|
-
record._get_product_amount_lines().mapped("other_value")
|
|
231
|
-
)
|
|
232
|
-
for line in record._get_product_amount_lines()[:-1]:
|
|
233
|
-
line.other_value = amount_other_value * (
|
|
234
|
-
line.other_value / amount_other_old
|
|
235
|
-
)
|
|
236
|
-
record._get_product_amount_lines()[-1].other_value = (
|
|
237
|
-
amount_other_value
|
|
238
|
-
- sum(
|
|
239
|
-
line.other_value
|
|
240
|
-
for line in record._get_product_amount_lines()[:-1]
|
|
241
|
-
)
|
|
242
|
-
)
|
|
243
|
-
else:
|
|
244
|
-
amount_total = sum(
|
|
245
|
-
record._get_product_amount_lines().mapped("price_gross")
|
|
246
|
-
)
|
|
247
|
-
for line in record._get_product_amount_lines()[:-1]:
|
|
248
|
-
if line.price_gross and amount_total:
|
|
249
|
-
line.other_value = amount_other_value * (
|
|
250
|
-
line.price_gross / amount_total
|
|
251
|
-
)
|
|
252
|
-
record._get_product_amount_lines()[-1].other_value = (
|
|
253
|
-
amount_other_value
|
|
254
|
-
- sum(
|
|
255
|
-
line.other_value
|
|
256
|
-
for line in record._get_product_amount_lines()[:-1]
|
|
257
|
-
)
|
|
258
|
-
)
|
|
259
|
-
for line in record._get_product_amount_lines():
|
|
260
|
-
line._onchange_fiscal_taxes()
|
|
261
|
-
record._fields["amount_total"].compute_value(record)
|
|
262
|
-
record.write(
|
|
263
|
-
{
|
|
264
|
-
name: value
|
|
265
|
-
for name, value in record._cache.items()
|
|
266
|
-
if record._fields[name].compute == "_amount_all"
|
|
267
|
-
and not record._fields[name].inverse
|
|
268
|
-
}
|
|
269
|
-
)
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
# Copyright (C) 2021 Renato Lima - Akretion <renato.lima@akretion.com.br>
|
|
2
|
-
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
|
3
|
-
|
|
4
|
-
from odoo import api, fields, models
|
|
5
|
-
|
|
6
|
-
from ..constants.fiscal import DOCUMENT_ISSUER_COMPANY
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class DocumentMoveMixin(models.AbstractModel):
|
|
10
|
-
_name = "l10n_br_fiscal.document.move.mixin"
|
|
11
|
-
_inherit = [
|
|
12
|
-
"l10n_br_fiscal.document.mixin.methods",
|
|
13
|
-
]
|
|
14
|
-
_description = "Move Document Fiscal Mixin"
|
|
15
|
-
|
|
16
|
-
partner_id = fields.Many2one(
|
|
17
|
-
comodel_name="res.partner",
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
partner_legal_name = fields.Char(
|
|
21
|
-
string="Legal Name",
|
|
22
|
-
related="partner_id.legal_name",
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
partner_name = fields.Char(
|
|
26
|
-
string="Partner Name",
|
|
27
|
-
related="partner_id.name",
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
partner_cnpj_cpf = fields.Char(
|
|
31
|
-
string="CNPJ",
|
|
32
|
-
related="partner_id.cnpj_cpf",
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
partner_inscr_est = fields.Char(
|
|
36
|
-
string="State Tax Number",
|
|
37
|
-
related="partner_id.inscr_est",
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
partner_ind_ie_dest = fields.Selection(
|
|
41
|
-
string="Contribuinte do ICMS",
|
|
42
|
-
related="partner_id.ind_ie_dest",
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
partner_inscr_mun = fields.Char(
|
|
46
|
-
string="Municipal Tax Number",
|
|
47
|
-
related="partner_id.inscr_mun",
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
partner_suframa = fields.Char(
|
|
51
|
-
string="Suframa",
|
|
52
|
-
related="partner_id.suframa",
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
partner_cnae_main_id = fields.Many2one(
|
|
56
|
-
comodel_name="l10n_br_fiscal.cnae",
|
|
57
|
-
string="Main CNAE",
|
|
58
|
-
related="partner_id.cnae_main_id",
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
partner_tax_framework = fields.Selection(
|
|
62
|
-
string="Tax Framework",
|
|
63
|
-
related="partner_id.tax_framework",
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
partner_street = fields.Char(
|
|
67
|
-
string="Partner Street",
|
|
68
|
-
related="partner_id.street",
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
partner_number = fields.Char(
|
|
72
|
-
string="Partner Number",
|
|
73
|
-
related="partner_id.street_number",
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
partner_street2 = fields.Char(
|
|
77
|
-
string="Partner Street2",
|
|
78
|
-
related="partner_id.street2",
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
partner_district = fields.Char(
|
|
82
|
-
string="Partner District",
|
|
83
|
-
related="partner_id.district",
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
partner_country_id = fields.Many2one(
|
|
87
|
-
comodel_name="res.country",
|
|
88
|
-
string="Partner Country",
|
|
89
|
-
related="partner_id.country_id",
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
partner_state_id = fields.Many2one(
|
|
93
|
-
comodel_name="res.country.state",
|
|
94
|
-
string="Partner State",
|
|
95
|
-
related="partner_id.state_id",
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
partner_city_id = fields.Many2one(
|
|
99
|
-
comodel_name="res.city",
|
|
100
|
-
string="Partner City",
|
|
101
|
-
related="partner_id.city_id",
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
partner_zip = fields.Char(
|
|
105
|
-
string="Partner Zip",
|
|
106
|
-
related="partner_id.zip",
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
partner_phone = fields.Char(
|
|
110
|
-
string="Partner Phone",
|
|
111
|
-
related="partner_id.phone",
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
partner_is_company = fields.Boolean(
|
|
115
|
-
string="Partner Is Company?",
|
|
116
|
-
related="partner_id.is_company",
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
company_id = fields.Many2one(
|
|
120
|
-
comodel_name="res.company",
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
processador_edoc = fields.Selection(
|
|
124
|
-
related="company_id.processador_edoc",
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
company_legal_name = fields.Char(
|
|
128
|
-
string="Company Legal Name",
|
|
129
|
-
related="company_id.legal_name",
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
company_name = fields.Char(
|
|
133
|
-
string="Company Name",
|
|
134
|
-
size=128,
|
|
135
|
-
related="company_id.name",
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
company_cnpj_cpf = fields.Char(
|
|
139
|
-
string="Company CNPJ",
|
|
140
|
-
related="company_id.cnpj_cpf",
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
company_inscr_est = fields.Char(
|
|
144
|
-
string="Company State Tax Number",
|
|
145
|
-
related="company_id.inscr_est",
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
company_inscr_est_st = fields.Char(
|
|
149
|
-
string="Company ST State Tax Number",
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
company_inscr_mun = fields.Char(
|
|
153
|
-
string="Company Municipal Tax Number",
|
|
154
|
-
related="company_id.inscr_mun",
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
company_suframa = fields.Char(
|
|
158
|
-
string="Company Suframa",
|
|
159
|
-
related="company_id.suframa",
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
company_cnae_main_id = fields.Many2one(
|
|
163
|
-
comodel_name="l10n_br_fiscal.cnae",
|
|
164
|
-
string="Company Main CNAE",
|
|
165
|
-
related="company_id.cnae_main_id",
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
company_tax_framework = fields.Selection(
|
|
169
|
-
string="Company Tax Framework",
|
|
170
|
-
related="company_id.tax_framework",
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
company_street = fields.Char(
|
|
174
|
-
string="Company Street",
|
|
175
|
-
related="company_id.street",
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
company_number = fields.Char(
|
|
179
|
-
string="Company Number",
|
|
180
|
-
related="company_id.street_number",
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
company_street2 = fields.Char(
|
|
184
|
-
string="Company Street2",
|
|
185
|
-
related="company_id.street2",
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
company_district = fields.Char(
|
|
189
|
-
string="Company District",
|
|
190
|
-
related="company_id.district",
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
company_country_id = fields.Many2one(
|
|
194
|
-
comodel_name="res.country",
|
|
195
|
-
string="Company Country",
|
|
196
|
-
related="company_id.country_id",
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
company_state_id = fields.Many2one(
|
|
200
|
-
comodel_name="res.country.state",
|
|
201
|
-
string="Company State",
|
|
202
|
-
related="company_id.state_id",
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
company_city_id = fields.Many2one(
|
|
206
|
-
comodel_name="res.city",
|
|
207
|
-
string="Company City",
|
|
208
|
-
related="company_id.city_id",
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
company_zip = fields.Char(
|
|
212
|
-
string="Company ZIP",
|
|
213
|
-
related="company_id.zip",
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
company_phone = fields.Char(
|
|
217
|
-
string="Company Phone",
|
|
218
|
-
related="company_id.phone",
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
@api.onchange("document_type_id")
|
|
222
|
-
def _onchange_document_type_id(self):
|
|
223
|
-
if self.document_type_id and self.issuer == DOCUMENT_ISSUER_COMPANY:
|
|
224
|
-
self.document_serie_id = self.document_type_id.get_document_serie(
|
|
225
|
-
self.company_id, self.fiscal_operation_id
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
@api.onchange("document_serie_id")
|
|
229
|
-
def _onchange_document_serie_id(self):
|
|
230
|
-
if self.document_serie_id and self.issuer == DOCUMENT_ISSUER_COMPANY:
|
|
231
|
-
self.document_serie = self.document_serie_id.code
|
|
232
|
-
|
|
233
|
-
@api.onchange("fiscal_operation_id")
|
|
234
|
-
def _onchange_fiscal_operation_id(self):
|
|
235
|
-
result = super()._onchange_fiscal_operation_id()
|
|
236
|
-
if self.fiscal_operation_id:
|
|
237
|
-
self.fiscal_operation_type = self.fiscal_operation_id.fiscal_operation_type
|
|
238
|
-
self.edoc_purpose = self.fiscal_operation_id.edoc_purpose
|
|
239
|
-
|
|
240
|
-
if self.issuer == DOCUMENT_ISSUER_COMPANY and not self.document_type_id:
|
|
241
|
-
self.document_type_id = self.company_id.document_type_id
|
|
242
|
-
|
|
243
|
-
subsequent_documents = [(6, 0, {})]
|
|
244
|
-
for subsequent_id in self.fiscal_operation_id.mapped(
|
|
245
|
-
"operation_subsequent_ids"
|
|
246
|
-
):
|
|
247
|
-
subsequent_documents.append(
|
|
248
|
-
(
|
|
249
|
-
0,
|
|
250
|
-
0,
|
|
251
|
-
{
|
|
252
|
-
"source_document_id": self.id,
|
|
253
|
-
"subsequent_operation_id": subsequent_id.id,
|
|
254
|
-
"fiscal_operation_id": (
|
|
255
|
-
subsequent_id.subsequent_operation_id.id
|
|
256
|
-
),
|
|
257
|
-
},
|
|
258
|
-
)
|
|
259
|
-
)
|
|
260
|
-
self.document_subsequent_ids = subsequent_documents
|
|
261
|
-
return result
|