Skip to content

Commit

Permalink
[FIX] l10n_br_cte: Fields Mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
lfdivino committed Oct 4, 2023
1 parent 177b4e5 commit f46e83b
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 23 deletions.
2 changes: 1 addition & 1 deletion l10n_br_cte/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# 'views/document_related.xml',
# 'views/res_partner.xml',
"views/res_company.xml",
# "views/cte_document.xml",
"views/cte_document.xml",
],
"post_init_hook": "post_init_hook",
"installable": True,
Expand Down
4 changes: 4 additions & 0 deletions l10n_br_cte/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
from . import aereo
from . import dutoviario
from . import aquaviario
from . import document_cargo_quantity_infos
from . import document_supplement
from . import document_transported_vehicles
from . import normal_cte_infos
78 changes: 66 additions & 12 deletions l10n_br_cte/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,48 @@ def _compute_imp(self):
default="cte40_infCTeNorm",
)

cte40_infCarga = fields.One2many(
comodel_name="l10n_br_fiscal.document.related",
string="Informações de quantidades da Carga do CTe",
cte40_infCTeNorm = fields.One2many(
comodel_name="l10n_br_cte.normal.infos",
inverse_name="document_id",
)

cte40_infCTeNorm = fields.One2many(
comodel_name="l10n_br_fiscal.document.related",
# cte40_infCTeComp = fields.One2many(
# comodel_name="l10n_br_fiscal.document.related",
# inverse_name="document_id",
# )

##########################
# CT-e tag: infCarga
##########################

cte40_vCarga = fields.Monetary(
string="Valor total da carga",
)

cte40_proPred = fields.Char(
string="Produto predominante",
required=True,
)

cte40_xOutCat = fields.Char(
string="Outras características da carga",
)

cte40_infQ = fields.One2many(
comodel_name="l10n_br_cte.cargo.quantity.infos",
inverse_name="document_id",
)

cte40_infCTeComp = fields.One2many(
comodel_name="l10n_br_fiscal.document.related",
cte40_vCargaAverb = fields.Monetary(
string="Valor da Carga para efeito de averbação",
)

##########################
# CT-e tag: veicNovos
##########################

cte40_veicNovos = fields.One2many(
comodel_name="l10n_br_cte.transported.vehicles",
inverse_name="document_id",
)

Expand All @@ -454,12 +483,9 @@ def _compute_imp(self):
def _default_cte40_autxml(self):
company = self.env.company
authorized_partners = []
if company.accountant_id and company.cte_authorize_accountant_download_xml:
if company.accountant_id:
authorized_partners.append(company.accountant_id.id)
if (
company.technical_support_id
and company.cte_authorize_technical_download_xml
):
if company.technical_support_id:
authorized_partners.append(company.technical_support_id.id)
return authorized_partners

Expand All @@ -469,6 +495,34 @@ def _default_cte40_autxml(self):

cte40_autXML = fields.One2many(default=_default_cte40_autxml)

##########################
# NF-e tag: infCTeSupl
##########################

cte40_infCTeSupl = fields.Many2one(
comodel_name="l10n_br_fiscal.document.supplement",
)

##########################
# MDF-e tag: infRespTec
##########################

cte40_infRespTec = fields.Many2one(
comodel_name="res.partner",
compute="_compute_infresptec",
string="Responsável Técnico MDFe",
)

##########################
# MDF-e tag: infRespTec
# Methods
##########################

@api.depends("company_id.technical_support_id")
def _compute_infresptec(self):
for record in self.filtered(filter_processador_edoc_cte):
record.cte40_infRespTec = record.company_id.technical_support_id

##########################
# CT-e tag: infmodal
##########################
Expand Down
27 changes: 27 additions & 0 deletions l10n_br_cte/models/document_cargo_quantity_infos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2023 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields

from odoo.addons.spec_driven_model.models import spec_models


class CTeCargoQuantityInfos(spec_models.SpecModel):
_name = "l10n_br_cte.cargo.quantity.infos"
_inherit = "cte.40.tcte_infq"
_binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00"
_description = "Informações de quantidades da Carga do CT-e"

document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document")

cte40_cUnid = fields.Selection(
required=True,
)

cte40_tpMed = fields.Char(
required=True,
)

cte40_qCarga = fields.Float(
required=True,
)
22 changes: 22 additions & 0 deletions l10n_br_cte/models/document_supplement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 KMEE (Luiz Felipe do Divino <luiz.divino@kmee.com.br>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields

from odoo.addons.spec_driven_model.models import spec_models


class CTeSupplement(spec_models.StackedModel):
_name = "l10n_br_fiscal.document.supplement"
_inherit = ["l10n_br_fiscal.document.supplement", "cte.40.tcte_infctesupl"]
_stacked = "cte.40.tcte_infctesupl"
_schema_name = "cte"
_schema_version = "4.0.0"
_odoo_module = "l10n_br_cte"
_spec_module = "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00"
_binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00"
_field_prefix = "cte40_"
_spec_tab_name = "CTe"
_description = "Informações Complementares do Documento Fiscal"

cte40_qrCodCTe = fields.Char(related="qrcode")
46 changes: 46 additions & 0 deletions l10n_br_cte/models/document_transported_vehicles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2023 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields

from odoo.addons.spec_driven_model.models import spec_models


class CTeCargoQuantityInfos(spec_models.SpecModel):
_name = "l10n_br_cte.transported.vehicles"
_inherit = "cte.40.veicnovos"
_binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00"
_description = "Informações dos veículos transportados"

document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document")

currency_id = fields.Many2one(
comodel_name="res.currency",
related="document_id.company_id.currency_id",
)

cte40_chassi = fields.Char(string="Chassi do veículo", required=True)

cte40_cCor = fields.Char(
string="Cor do veículo",
required=True,
)

cte40_xCor = fields.Char(string="Descrição da cor", required=True)

cte40_cMod = fields.Char(
string="Código Marca Modelo",
required=True,
)

cte40_vUnit = fields.Monetary(
string="Valor Unitário do Veículo",
required=True,
currency_field="currency_id",
)

cte40_vFrete = fields.Monetary(
string="Frete Unitário",
required=True,
currency_field="currency_id",
)
60 changes: 60 additions & 0 deletions l10n_br_cte/models/normal_cte_infos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2023 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields

from odoo.addons.spec_driven_model.models import spec_models


class CTeNormalInfos(spec_models.StackedModel):
_name = "l10n_br_cte.normal.infos"
_inherit = ["cte.40.tcte_infctenorm"]
_stacked = "cte.40.tcte_infctenorm"
_field_prefix = "cte40_"
_schema_name = "cte"
_schema_version = "4.0.0"
_odoo_module = "l10n_br_cte"
_spec_module = "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00"
_binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00"
_spec_tab_name = "CTe"
_description = "Grupo de informações do CTe Normal e Substituto"
_force_stack_paths = "infctenorm.infdoc"

document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document")

currency_id = fields.Many2one(
comodel_name="res.currency",
related="document_id.company_id.currency_id",
)

cte40_vCarga = fields.Monetary(
related="document_id.cte40_vCarga",
currency_field="currency_id",
)

cte40_proPred = fields.Char(
related="document_id.cte40_proPred",
)

cte40_xOutCat = fields.Char(
related="document_id.cte40_xOutCat",
)

cte40_infQ = fields.One2many(
comodel_name="l10n_br_cte.cargo.quantity.infos",
related="document_id.cte40_infQ",
)

cte40_vCargaAverb = fields.Monetary(
related="document_id.cte40_vCargaAverb",
)

cte40_veicNovos = fields.One2many(
comodel_name="l10n_br_cte.transported.vehicles",
related="document_id.cte40_veicNovos",
)

cte40_infNFe = fields.One2many(
comodel_name="l10n_br_fiscal.document.related",
related="document_id.document_related_ids",
)
4 changes: 4 additions & 0 deletions l10n_br_cte/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ l10n_br_cte_modal_ferroviario_tenderfer_user,l10n_br_cte_modal_ferroviario_tende

l10n_br_cte_modal_aquaviario_user,l10n_br_cte_modal_aquaviario_user,model_l10n_br_cte_modal_aquaviario,base.group_user,1,1,1,1
l10n_br_cte_modal_dutoviario_user,l10n_br_cte_modal_dutoviario_user,model_l10n_br_cte_modal_dutoviario,base.group_user,1,1,1,1

l10n_br_cte_normal_infos_user,l10n_br_cte_normal_infos_user,model_l10n_br_cte_normal_infos,base.group_user,1,1,1,1
l10n_br_cte_cargo_quantity_infos_user,l10n_br_cte_cargo_quantity_infos_user,model_l10n_br_cte_cargo_quantity_infos,base.group_user,1,1,1,1
l10n_br_cte_transported_vehicles_user,l10n_br_cte_transported_vehicles_user,model_l10n_br_cte_transported_vehicles,base.group_user,1,1,1,1
Binary file modified l10n_br_cte/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 49 additions & 10 deletions l10n_br_cte/views/cte_document.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,55 @@
name="invisible"
>[('document_type_id.code', 'in', ['57', '08', '09', '10', '11', '26', '67', '8B'])]</attribute>
</xpath>
<xpath expr="//page[@name='products']" position="attributes">
<attribute
name="invisible"
>[('document_type_id.code', 'in', ['57', '08', '09', '10', '11', '26', '67', '8B'])]</attribute>
</xpath>
<xpath expr="//page[@name='finance']" position="attributes">
<attribute
name="invisible"
>[('document_type_id.code', 'in', ['57', '08', '09', '10', '11', '26', '67', '8B'])]</attribute>
</xpath>
<page name="delivery" position="inside">
<separator name="cargo_infos_sep" string="Cargo Infos" />
<group name="cargo_infos">
<field name="cte40_vCarga" />
<field name="cte40_proPred" />
<field name="cte40_xOutCat" />
<field name="cte40_vCargaAverb" />
<field name="cte40_infQ">
<tree>
<field name="cte40_cUnid" />
<field name="cte40_tpMed" />
<field name="cte40_qCarga" />
</tree>
<form>
<group>
<field name="cte40_cUnid" />
<field name="cte40_tpMed" />
<field name="cte40_qCarga" />
</group>
</form>
</field>
</group>
<separator
name="transported_vehicles_infos_sep"
string="Transported Vehicles"
/>
<group name="transported_vehicles_infos">
<field name="cte40_veicNovos">
<tree>
<field name="cte40_chassi" />
<field name="cte40_cCor" />
<field name="cte40_xCor" />
<field name="cte40_cMod" />
<field name="cte40_vUnit" />
<field name="cte40_vFrete" />
</tree>
<form>
<group>
<field name="cte40_chassi" />
<field name="cte40_cCor" />
<field name="cte40_xCor" />
<field name="cte40_cMod" />
<field name="cte40_vUnit" />
<field name="cte40_vFrete" />
</group>
</form>
</field>
</group>
</page>
</field>
</record>

Expand Down

0 comments on commit f46e83b

Please sign in to comment.