From 8a756f33bb8f09d431a0c97bf0fa4c6f784da570 Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Fri, 25 Oct 2024 17:27:03 -0300 Subject: [PATCH] [RFC] l10n_br_cte: multi-schema refactor --- l10n_br_cte/hooks.py | 41 +++++-- l10n_br_cte/models/__init__.py | 5 +- l10n_br_cte/models/aereo.py | 26 ++--- l10n_br_cte/models/aquaviario.py | 13 +-- l10n_br_cte/models/document.py | 102 +++++++++--------- .../models/document_cargo_quantity_infos.py | 1 - .../{comment.py => document_comment.py} | 18 ++-- l10n_br_cte/models/document_line.py | 18 ++-- l10n_br_cte/models/document_related.py | 13 +-- l10n_br_cte/models/document_supplement.py | 13 +-- .../models/document_transported_vehicles.py | 1 - l10n_br_cte/models/dutoviario.py | 6 +- l10n_br_cte/models/ferroviario.py | 13 +-- l10n_br_cte/models/normal_cte_infos.py | 15 ++- l10n_br_cte/models/res_partner.py | 2 - l10n_br_cte/models/rodoviario.py | 26 ++--- 16 files changed, 152 insertions(+), 161 deletions(-) rename l10n_br_cte/models/{comment.py => document_comment.py} (73%) diff --git a/l10n_br_cte/hooks.py b/l10n_br_cte/hooks.py index 572921aaf117..6348b345b35b 100644 --- a/l10n_br_cte/hooks.py +++ b/l10n_br_cte/hooks.py @@ -1,13 +1,42 @@ # Copyright (C) 2019-2020 - Raphael Valyi Akretion # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +import logging + +import nfelib +import pkg_resources +from nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00 import Tcte + from odoo import SUPERUSER_ID, api +from odoo.exceptions import ValidationError + +_logger = logging.getLogger(__name__) def post_init_hook(cr, registry): env = api.Environment(cr, SUPERUSER_ID, {}) - env["cte.40.tcte_infcte"]._register_hook() - # hooks.register_hook( - # env, - # "l10n_br_cte", - # "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00", - # ) + cr.execute("select demo from ir_module_module where name='l10n_br_cte';") + is_demo = cr.fetchone()[0] + if is_demo: + res_items = ( + "cte", + "samples", + "v3_0", + "43120178408960000182570010000000041000000047-cte.xml", + ) + resource_path = "/".join(res_items) + doc_stream = pkg_resources.resource_stream(nfelib.__name__, resource_path) + binding = Tcte.from_xml(doc_stream.read().decode()) + document_number = binding.infCte.ide.nCTE + existing_docs = env["l10n_br_fiscal.document"].search( + [("document_number", "=", document_number)] + ) + try: + existing_docs.unlink() + doc = ( + env["cte.40.tcte_infcte"] + .with_context(tracking_disable=True, edoc_type="in") + .build_from_binding("cte", "40", binding.infMDFe) + ) + _logger.info(doc.cte40_emit.cte40_CNPJ) + except ValidationError: + _logger.info(f"CTE-e already {document_number} imported by hooks") diff --git a/l10n_br_cte/models/__init__.py b/l10n_br_cte/models/__init__.py index 40014e44edb5..2082b680910c 100644 --- a/l10n_br_cte/models/__init__.py +++ b/l10n_br_cte/models/__init__.py @@ -13,4 +13,7 @@ from . import document_supplement from . import document_transported_vehicles from . import normal_cte_infos -from . import comment +from . import document_comment + +spec_schema = "cte" +spec_version = "40" diff --git a/l10n_br_cte/models/aereo.py b/l10n_br_cte/models/aereo.py index 894273a09dd5..f5f69c888dba 100644 --- a/l10n_br_cte/models/aereo.py +++ b/l10n_br_cte/models/aereo.py @@ -10,16 +10,13 @@ class Aereo(spec_models.StackedModel): _name = "l10n_br_cte.modal.aereo" _inherit = "cte.40.aereo" - _stacked = "cte.40.aereo" - _binding_module = "nfelib.cte.bindings.v4_0.cte_modal_aereo_v4_00" - _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_modal_aereo_v4_00" - _spec_tab_name = "CTe" _description = "Modal Aereo CTe" + _cte40_stacking_mixin = "cte.40.aereo" + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_modal_aereo_v4_00" + ) + document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document") cte40_nMinu = fields.Char(related="document_id.cte40_nMinu") @@ -46,18 +43,15 @@ def _prepare_dacte_values(self): class Peri(spec_models.StackedModel): _name = "l10n_br_cte.modal.aereo.peri" _inherit = "cte.40.peri" - _stacked = "cte.40.peri" - _binding_module = "nfelib.cte.bindings.v4_0.cte_modal_aereo_v4_00" - _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_modal_aereo_v4_00" - _spec_tab_name = "CTe" _description = """Preenchido quando for transporte de produtos classificados pela ONU como perigosos. O preenchimento desses campos não desobriga a empresa aérea de emitir os demais documentos que constam na legislação vigente.""" + _cte40_stacking_mixin = "cte.40.peri" + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_modal_aereo_v4_00" + ) + document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document") cte40_nONU = fields.Char(required=True) diff --git a/l10n_br_cte/models/aquaviario.py b/l10n_br_cte/models/aquaviario.py index 54709b03fba0..be9f52967d74 100644 --- a/l10n_br_cte/models/aquaviario.py +++ b/l10n_br_cte/models/aquaviario.py @@ -9,16 +9,13 @@ class Aquav(spec_models.StackedModel): _name = "l10n_br_cte.modal.aquav" _inherit = "cte.40.aquav" - _stacked = "cte.40.aquav" - _binding_module = "nfelib.cte.bindings.v4_0.cte_modal_aquaviario_v4_00" - _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_modal_aquaviario_v4_00" - _spec_tab_name = "CTe" _description = "Modal Aquaviário CTe" + _cte40_stacking_mixin = "cte.40.aquav" + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_modal_aquaviario_v4_00" + ) + document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document") cte40_vAFRMM = fields.Monetary(related="document_id.cte40_vAFRMM") diff --git a/l10n_br_cte/models/document.py b/l10n_br_cte/models/document.py index 66c6b4b11a9a..f2945c66e594 100644 --- a/l10n_br_cte/models/document.py +++ b/l10n_br_cte/models/document.py @@ -83,29 +83,24 @@ class CTe(spec_models.StackedModel): "cte.40.tcte_imp", "cte.40.tcte_fat", ] - _stacked = "cte.40.tcte_infcte" - _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" - _spec_tab_name = "CTe" - _binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00" - _stack_skip = ( + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00" + ) + _cte40_stacking_mixin = "cte.40.tcte_infcte" + _cte40_stacking_skip_paths = ( "cte40_fluxo", "cte40_semData", "cte40_noInter", "cte40_comHora", "cte40_noPeriodo", ) - _cte_search_keys = ["cte40_Id"] - # all m2o at this level will be stacked even if not required: - _force_stack_paths = ( + _cte40_stacking_force_paths = ( "infcte.compl", "infcte.compl.entrega" "infcte.vprest", "infcte.imp", ) + _cte_search_keys = ["cte40_Id"] INFCTE_TREE = """ > infCte @@ -1107,7 +1102,6 @@ def _compute_cte40_RNTRC(self): ########################## def _export_fields_cte_40_tcte_infmodal(self, xsd_fields, class_obj, export_dict): - self = self.with_context(module="l10n_br_cte") if self.cte40_modal == "01": export_dict["any_element"] = self._export_modal_rodoviario() elif self.cte40_modal == "02": @@ -1123,7 +1117,7 @@ def _export_modal_aereo(self): if not self.modal_aereo_id: self.modal_aereo_id = self.modal_aereo_id.create({"document_id": self.id}) - return self.modal_aereo_id.export_ds()[0] + return self.modal_aereo_id._build_binding("cte", "40") def _export_modal_ferroviario(self): if not self.modal_ferroviario_id: @@ -1131,7 +1125,7 @@ def _export_modal_ferroviario(self): {"document_id": self.id} ) - return self.modal_ferroviario_id.export_ds()[0] + return self.modal_ferroviario_id._build_binding("cte", "40") def _export_modal_aquaviario(self): if not self.modal_aquaviario_id: @@ -1139,7 +1133,7 @@ def _export_modal_aquaviario(self): {"document_id": self.id} ) - return self.modal_aquaviario_id.export_ds()[0] + return self.modal_aquaviario_id._build_binding("cte", "40") def _export_modal_rodoviario(self): if not self.modal_rodoviario_id: @@ -1147,7 +1141,7 @@ def _export_modal_rodoviario(self): {"document_id": self.id} ) - return self.modal_rodoviario_id.export_ds()[0] + return self.modal_rodoviario_id._build_binding("cte", "40") def _export_modal_dutoviario(self): if not self.modal_dutoviario_id: @@ -1155,7 +1149,7 @@ def _export_modal_dutoviario(self): {"document_id": self.id} ) - return self.modal_dutoviario_id.export_ds()[0] + return self.modal_dutoviario_id._build_binding("cte", "40") ################################ # Framework Spec model's methods @@ -1182,15 +1176,15 @@ def _serialize(self, edocs): for record in self.with_context(lang="pt_BR").filtered( filter_processador_edoc_cte ): - inf_cte = record.export_ds()[0] + inf_cte = record._build_binding("cte", "40") inf_cte_supl = None if record.cte40_infCTeSupl: - inf_cte_supl = record.cte40_infCTeSupl.export_ds()[0] + inf_cte_supl = record.cte40_infCTeSupl._build_binding("cte", "40") cte = Cte(infCte=inf_cte, infCTeSupl=inf_cte_supl, signature=None) edocs.append(cte) return edocs - def _processador(self): + def _edoc_processor(self): if not self.company_id.certificate_nfe_id: raise UserError(_("Certificado não encontrado")) @@ -1209,7 +1203,7 @@ def _document_export(self, pretty_print=True): result = super()._document_export() for record in self.filtered(filter_processador_edoc_cte): edoc = record.serialize()[0] - processador = record._processador() + processador = record._edoc_processor() xml_file = edoc.to_xml() event_id = self.event_ids.create_event_save_xml( company_id=self.company_id, @@ -1222,26 +1216,26 @@ def _document_export(self, pretty_print=True): ) record.authorization_event_id = event_id xml_assinado = processador.assina_raiz(edoc, edoc.infCte.Id) - self._valida_xml(xml_assinado) + self._validate_xml(xml_assinado) return result - def _valida_xml(self, xml_file): + def _validate_xml(self, xml_file): self.ensure_one() erros = Cte.schema_validation(xml_file) erros = "\n".join(erros) self.write({"xml_error_message": erros or False}) - def atualiza_status_cte(self, processo): + def update_status_cte(self, process): self.ensure_one() - if hasattr(processo, "protocolo"): - infProt = processo.protocolo.infProt + if hasattr(process, "protocolo"): + infProt = process.protocolo.infProt else: - infProt = processo.resposta.protCTe.infProt + infProt = process.resposta.protCTe.infProt if infProt.cStat in AUTORIZADO: state = SITUACAO_EDOC_AUTORIZADA - self._cte_response_add_proc(processo) + self._cte_response_add_proc(process) elif infProt.cStat in DENEGADO: state = SITUACAO_EDOC_DENEGADA else: @@ -1259,7 +1253,7 @@ def atualiza_status_cte(self, processo): response=infProt.xMotivo, protocol_date=protocol_date, protocol_number=infProt.nProt, - file_response_xml=processo.processo_xml.decode("utf-8"), + file_response_xml=process.processo_xml.decode("utf-8"), ) self.write( { @@ -1274,25 +1268,25 @@ def _eletronic_document_send(self): for record in self.filtered(filter_processador_edoc_cte): if record.xml_error_message: return - processador = record._processador() + processador = record._edoc_processor() for edoc in record.serialize(): - processo = None + process = None for p in processador.processar_documento(edoc): - processo = p - if processo.webservice == "cteRecepcaoLote": + process = p + if process.webservice == "cteRecepcaoLote": record.authorization_event_id._save_event_file( - processo.envio_xml, "xml" + process.envio_xml, "xml" ) - if processo.resposta.cStat in LOTE_PROCESSADO + ["100"]: - record.atualiza_status_cte(processo) + if process.resposta.cStat in LOTE_PROCESSADO + ["100"]: + record.update_status_cte(process) - elif processo.resposta.cStat in DENEGADO: + elif process.resposta.cStat in DENEGADO: record._change_state(SITUACAO_EDOC_DENEGADA) record.write( { - "status_code": processo.resposta.cStat, - "status_name": processo.resposta.xMotivo, + "status_code": process.resposta.cStat, + "status_name": process.resposta.xMotivo, } ) @@ -1300,8 +1294,8 @@ def _eletronic_document_send(self): record._change_state(SITUACAO_EDOC_REJEITADA) record.write( { - "status_code": processo.resposta.cStat, - "status_name": processo.resposta.xMotivo, + "status_code": process.resposta.cStat, + "status_name": process.resposta.xMotivo, } ) @@ -1314,7 +1308,7 @@ def _document_cancel(self, justificative): def _cte_cancel(self): self.ensure_one() - processador = self._processador() + processador = self._edoc_processor() if not self.authorization_protocol: raise UserError(_("Authorization Protocol Not Found!")) @@ -1324,17 +1318,17 @@ def _cte_cancel(self): protocolo_autorizacao=self.authorization_protocol, justificativa=self.cancel_reason.replace("\n", "\\n"), ) - processo = processador.enviar_lote_evento(lista_eventos=[evento]) + process = processador.enviar_lote_evento(lista_eventos=[evento]) self.cancel_event_id = self.event_ids.create_event_save_xml( company_id=self.company_id, environment=(EVENT_ENV_PROD if self.cte40_tpAmb == "1" else EVENT_ENV_HML), event_type="2", - xml_file=processo.envio_xml, + xml_file=process.envio_xml, document_id=self, ) - resposta = processo.resposta.infEvento + resposta = process.resposta.infEvento if resposta.cStat not in CANCELADO: mensagem = "Erro no cancelamento" @@ -1356,7 +1350,7 @@ def _cte_cancel(self): datetime.fromisoformat(resposta.dhRegEvento) ), protocol_number=resposta.nProt, - file_response_xml=processo.retorno.content.decode("utf-8"), + file_response_xml=process.retorno.content.decode("utf-8"), ) def _document_correction(self, justificative): @@ -1368,7 +1362,7 @@ def _document_correction(self, justificative): def _cte_correction(self, justificative): self.ensure_one() - processador = self._processador() + processador = self._edoc_processor() numeros = self.event_ids.filtered( lambda e: e.type == "14" and e.state == "done" @@ -1382,19 +1376,19 @@ def _cte_correction(self, justificative): justificativa=justificative.replace("\n", "\\n"), sequencia=sequence, ) - processo = processador.enviar_lote_evento(lista_eventos=[evento]) + process = processador.enviar_lote_evento(lista_eventos=[evento]) # Gravamos o arquivo no disco e no filestore ASAP. event_id = self.event_ids.create_event_save_xml( company_id=self.company_id, environment=(EVENT_ENV_PROD if self.cte40_tpAmb == "1" else EVENT_ENV_HML), event_type="14", - xml_file=processo.envio_xml, + xml_file=process.envio_xml, document_id=self, sequence=sequence, justification=justificative, ) - resposta = processo.resposta.infEvento + resposta = process.resposta.infEvento if resposta.cStat not in EVENTO_RECEBIDO and not ( resposta.chCTe == self.document_key @@ -1411,7 +1405,7 @@ def _cte_correction(self, justificative): datetime.fromisoformat(resposta.dhRegEvento) ), protocol_number=resposta.nProt, - file_response_xml=processo.retorno.content.decode("utf-8"), + file_response_xml=process.retorno.content.decode("utf-8"), ) def _document_qrcode(self): @@ -1430,7 +1424,7 @@ def get_cte_qrcode(self): # if self.document_type != MODELO_FISCAL_CTE: # return - processador = self._processador() + processador = self._edoc_processor() # if self.nfe_transmission == "1": # return processador.monta_qrcode(self.document_key) return processador.monta_qrcode(self.document_key) @@ -1544,7 +1538,7 @@ def _cte_create_proc(self, prot_element): ) return None - processor = self._processador() + processor = self._edoc_processor() # Extract the tag from the `enviCTe` message, which represents the CT-e xml_send = base64.b64decode(self.send_file_id.datas) diff --git a/l10n_br_cte/models/document_cargo_quantity_infos.py b/l10n_br_cte/models/document_cargo_quantity_infos.py index 44ea62fba70b..57b5e99397c2 100644 --- a/l10n_br_cte/models/document_cargo_quantity_infos.py +++ b/l10n_br_cte/models/document_cargo_quantity_infos.py @@ -9,7 +9,6 @@ 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") diff --git a/l10n_br_cte/models/comment.py b/l10n_br_cte/models/document_comment.py similarity index 73% rename from l10n_br_cte/models/comment.py rename to l10n_br_cte/models/document_comment.py index dba4685a3278..215ed802dec5 100644 --- a/l10n_br_cte/models/comment.py +++ b/l10n_br_cte/models/document_comment.py @@ -9,16 +9,14 @@ class CTeComment(spec_models.StackedModel): _name = "l10n_br_fiscal.comment" _inherit = ["l10n_br_fiscal.comment", "cte.40.tcte_obscont", "cte.40.tcte_obsfisco"] - _stacked = "cte.40.tcte_obscont" - _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" - _spec_tab_name = "CTe" - _stacking_points = {} - _stack_skip = ("cte40_ObsCont_compl_id", "cte40_ObsFisco_compl_id") - _binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00" + + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00" + ) + _cte40_stacking_mixin = "cte.40.tcte_obscont" + + # _stacking_points = {} + _cte40_stacking_skip_paths = ("cte40_ObsCont_compl_id", "cte40_ObsFisco_compl_id") cte40_xCampo = fields.Char() diff --git a/l10n_br_cte/models/document_line.py b/l10n_br_cte/models/document_line.py index df7ef721f09b..f1a2c2ed53ad 100644 --- a/l10n_br_cte/models/document_line.py +++ b/l10n_br_cte/models/document_line.py @@ -9,16 +9,14 @@ class CTeLine(spec_models.StackedModel): _name = "l10n_br_fiscal.document.line" _inherit = ["l10n_br_fiscal.document.line", "cte.40.tcte_vprest_comp"] - _stacked = "cte.40.tcte_vprest_comp" - _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" - _spec_tab_name = "CTe" - _stacking_points = {} - _stack_skip = ("cte40_Comp_vPrest_id",) - _binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00" + + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00" + ) + _cte40_stacking_mixin = "cte.40.tcte_vprest_comp" + + # _stacking_points = {} + _cte40_stacking_skip_paths = ("cte40_Comp_vPrest_id",) ########################## # CT-e tag: comp diff --git a/l10n_br_cte/models/document_related.py b/l10n_br_cte/models/document_related.py index 5ab80e398d57..f68d6770d7d0 100644 --- a/l10n_br_cte/models/document_related.py +++ b/l10n_br_cte/models/document_related.py @@ -12,14 +12,11 @@ class CTeRelated(spec_models.StackedModel): "l10n_br_fiscal.document.related", "cte.40.tcte_infdoc", ] - _stacked = "cte.40.tcte_infdoc" - _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" - _spec_tab_name = "CTe" - _binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00" + + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00" + ) + _cte40_stacking_mixin = "cte.40.tcte_infdoc" # InfNFe cte40_chave = fields.Char( diff --git a/l10n_br_cte/models/document_supplement.py b/l10n_br_cte/models/document_supplement.py index 10fd555c1514..9625c7441c19 100644 --- a/l10n_br_cte/models/document_supplement.py +++ b/l10n_br_cte/models/document_supplement.py @@ -9,13 +9,10 @@ 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" - _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" - _spec_tab_name = "CTe" - _binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00" + + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00" + ) + _cte40_stacking_mixin = "cte.40.tcte_infctesupl" 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 index bbb6af6bfd07..004ce2627172 100644 --- a/l10n_br_cte/models/document_transported_vehicles.py +++ b/l10n_br_cte/models/document_transported_vehicles.py @@ -9,7 +9,6 @@ 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") diff --git a/l10n_br_cte/models/dutoviario.py b/l10n_br_cte/models/dutoviario.py index 8d980571c62c..51d479d08b61 100644 --- a/l10n_br_cte/models/dutoviario.py +++ b/l10n_br_cte/models/dutoviario.py @@ -6,12 +6,14 @@ from odoo.addons.spec_driven_model.models import spec_models -class Duto(spec_models.SpecModel): +class Duto(spec_models.StackedModel): _name = "l10n_br_cte.modal.duto" _inherit = "cte.40.duto" - _binding_module = "nfelib.cte.bindings.v4_0.cte_modal_dutoviario_v4_00" _description = "Modal Dutoviario CTe" + _cte40_stacking_mixin = "cte.40.duto" + _cte40_odoo_module = "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_modal_duto_v4_00" + document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document") cte40_dIni = fields.Date(related="document_id.cte40_dIni") diff --git a/l10n_br_cte/models/ferroviario.py b/l10n_br_cte/models/ferroviario.py index d18932706e1f..d3048e812212 100644 --- a/l10n_br_cte/models/ferroviario.py +++ b/l10n_br_cte/models/ferroviario.py @@ -10,17 +10,12 @@ class Ferrov(spec_models.StackedModel): _name = "l10n_br_cte.modal.ferrov" _inherit = "cte.40.ferrov" - _stacked = "cte.40.ferrov" - _binding_module = "nfelib.cte.bindings.v4_0.cte_modal_ferroviario_v4_00" - _field_prefix = "cte40_" - _schema_name = "cte" - _schema_version = "4.0.0" - _odoo_module = "l10n_br_cte" - _spec_module = ( + _description = "Modal Ferroviario CTe" + + _cte40_stacking_mixin = "cte.40.ferrov" + _cte40_odoo_module = ( "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_modal_ferroviario_v4_00" ) - _spec_tab_name = "CTe" - _description = "Modal Ferroviario CTe" document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document") diff --git a/l10n_br_cte/models/normal_cte_infos.py b/l10n_br_cte/models/normal_cte_infos.py index 71165a69ad6b..9a893311c3b4 100644 --- a/l10n_br_cte/models/normal_cte_infos.py +++ b/l10n_br_cte/models/normal_cte_infos.py @@ -9,16 +9,13 @@ 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" + + _cte40_stacking_mixin = "cte.40.tcte_infctenorm" + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_tipos_basico_v4_00" + ) + _cte40_stacking_force_paths = "infctenorm.infdoc" document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document") diff --git a/l10n_br_cte/models/res_partner.py b/l10n_br_cte/models/res_partner.py index a669c1e2b692..aab363047245 100644 --- a/l10n_br_cte/models/res_partner.py +++ b/l10n_br_cte/models/res_partner.py @@ -28,8 +28,6 @@ class ResPartner(spec_models.SpecModel): "cte.40.tenderfer", ] _cte_search_keys = ["cte40_CNPJ", "cte40_CPF", "cte40_xNome"] - _binding_module = "nfelib.cte.bindings.v4_0.cte_tipos_basico_v4_00" - _field_prefix = "cte40_" cte40_choice_cnpj_cpf = fields.Selection( selection=[("cte40_CNPJ", "CNPJ"), ("cte40_CPF", "CPF")], diff --git a/l10n_br_cte/models/rodoviario.py b/l10n_br_cte/models/rodoviario.py index 7a52647dc089..11d63261a597 100644 --- a/l10n_br_cte/models/rodoviario.py +++ b/l10n_br_cte/models/rodoviario.py @@ -11,16 +11,13 @@ class Rodo(spec_models.StackedModel): _name = "l10n_br_cte.modal.rodo" _inherit = "cte.40.rodo" - _stacked = "cte.40.rodo" - _binding_module = "nfelib.cte.bindings.v4_0.cte_modal_rodoviario_v4_00" - _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_modal_rodoviario_v4_00" - _spec_tab_name = "CTe" _description = "Modal Rodoviario CTe" + _cte40_stacking_mixin = "cte.40.rodo" + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_modal_rodoviario_v4_00" + ) + document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document") cte40_RNTRC = fields.Char(related="document_id.cte40_RNTRC") @@ -31,16 +28,13 @@ class Rodo(spec_models.StackedModel): class Occ(spec_models.StackedModel): _name = "l10n_br_cte.modal.rodo.occ" _inherit = "cte.40.occ" - _stacked = "cte.40.occ" - _binding_module = "nfelib.cte.bindings.v4_0.cte_modal_rodoviario_v4_00" - _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_modal_rodoviario_v4_00" - _spec_tab_name = "CTe" _description = "Ordens de Coleta associados" + _cte40_stacking_mixin = "cte.40.occ" + _cte40_odoo_module = ( + "odoo.addons.l10n_br_cte_spec.models.v4_0.cte_modal_rodoviario_v4_00" + ) + document_id = fields.Many2one(comodel_name="l10n_br_fiscal.document") cte40_serie = fields.Char(string="Série da OCC")