diff --git a/l10n_br_cte/__manifest__.py b/l10n_br_cte/__manifest__.py index f94471e7b9d8..eeec72995bd7 100644 --- a/l10n_br_cte/__manifest__.py +++ b/l10n_br_cte/__manifest__.py @@ -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, diff --git a/l10n_br_cte/models/__init__.py b/l10n_br_cte/models/__init__.py index df5d3abbb98e..3aac89ccbd32 100644 --- a/l10n_br_cte/models/__init__.py +++ b/l10n_br_cte/models/__init__.py @@ -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 diff --git a/l10n_br_cte/models/document.py b/l10n_br_cte/models/document.py index 81a76ce5dd5a..b4749c66f63f 100644 --- a/l10n_br_cte/models/document.py +++ b/l10n_br_cte/models/document.py @@ -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", ) @@ -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 @@ -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 ########################## diff --git a/l10n_br_cte/models/document_cargo_quantity_infos.py b/l10n_br_cte/models/document_cargo_quantity_infos.py new file mode 100644 index 000000000000..f8bab3197ca0 --- /dev/null +++ b/l10n_br_cte/models/document_cargo_quantity_infos.py @@ -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, + ) diff --git a/l10n_br_cte/models/document_supplement.py b/l10n_br_cte/models/document_supplement.py new file mode 100644 index 000000000000..d4202faf2e78 --- /dev/null +++ b/l10n_br_cte/models/document_supplement.py @@ -0,0 +1,22 @@ +# Copyright 2023 KMEE (Luiz Felipe do Divino ) +# 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") diff --git a/l10n_br_cte/models/document_transported_vehicles.py b/l10n_br_cte/models/document_transported_vehicles.py new file mode 100644 index 000000000000..d704046daa8d --- /dev/null +++ b/l10n_br_cte/models/document_transported_vehicles.py @@ -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", + ) diff --git a/l10n_br_cte/models/normal_cte_infos.py b/l10n_br_cte/models/normal_cte_infos.py new file mode 100644 index 000000000000..46db99fd8191 --- /dev/null +++ b/l10n_br_cte/models/normal_cte_infos.py @@ -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", + ) diff --git a/l10n_br_cte/security/ir.model.access.csv b/l10n_br_cte/security/ir.model.access.csv index 181afac1994b..0ef67eb73965 100644 --- a/l10n_br_cte/security/ir.model.access.csv +++ b/l10n_br_cte/security/ir.model.access.csv @@ -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 diff --git a/l10n_br_cte/static/description/icon.png b/l10n_br_cte/static/description/icon.png index 3a0328b516c4..4515bffd318d 100644 Binary files a/l10n_br_cte/static/description/icon.png and b/l10n_br_cte/static/description/icon.png differ diff --git a/l10n_br_cte/views/cte_document.xml b/l10n_br_cte/views/cte_document.xml index ab9efc866db2..bd138825af0e 100644 --- a/l10n_br_cte/views/cte_document.xml +++ b/l10n_br_cte/views/cte_document.xml @@ -19,16 +19,55 @@ name="invisible" >[('document_type_id.code', 'in', ['57', '08', '09', '10', '11', '26', '67', '8B'])] - - [('document_type_id.code', 'in', ['57', '08', '09', '10', '11', '26', '67', '8B'])] - - - [('document_type_id.code', 'in', ['57', '08', '09', '10', '11', '26', '67', '8B'])] - + + + + + + + + + + + + + +
+ + + + + +
+
+
+ + + + + + + + + + + +
+ + + + + + + + +
+
+
+