Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] l10n_br_mdfe: fix fields and methods names #3498

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 32 additions & 30 deletions l10n_br_mdfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def _compute_mdfe30_inf_percurso(self):
mdfe30_versaoModal = fields.Char(default=MDFE_MODAL_VERSION_DEFAULT)

# Campos do Modal Aéreo
modal_aereo_id = fields.Many2one(
mdfe_modal_aereo_id = fields.Many2one(
comodel_name="l10n_br_mdfe.modal.aereo", copy=False
)

Expand All @@ -376,7 +376,7 @@ def _compute_mdfe30_inf_percurso(self):
)

# Campos do Modal Aquaviário
modal_aquaviario_id = fields.Many2one(
mdfe_modal_aquaviario_id = fields.Many2one(
comodel_name="l10n_br_mdfe.modal.aquaviario", copy=False
)

Expand Down Expand Up @@ -433,7 +433,7 @@ def _compute_mdfe30_inf_percurso(self):
)

# Campos do Modal Ferroviário
modal_ferroviario_id = fields.Many2one(
mdfe_modal_ferroviario_id = fields.Many2one(
comodel_name="l10n_br_mdfe.modal.ferroviario", copy=False
)

Expand All @@ -452,7 +452,7 @@ def _compute_mdfe30_inf_percurso(self):
)

# Campos do Modal Rodoviário
modal_rodoviario_id = fields.Many2one(
mdfe_modal_rodoviario_id = fields.Many2one(
comodel_name="l10n_br_mdfe.modal.rodoviario", copy=False
)

Expand Down Expand Up @@ -543,43 +543,45 @@ def _compute_mdfe30_rodo_uf(self):

def _export_fields_mdfe_30_infmodal(self, xsd_fields, class_obj, export_dict):
if self.mdfe_modal == "1":
export_dict["any_element"] = self._export_modal_rodoviario()
export_dict["any_element"] = self._export_mdfe_modal_rodoviario()
elif self.mdfe_modal == "2":
export_dict["any_element"] = self._export_modal_aereo()
export_dict["any_element"] = self._export_mdfe_modal_aereo()
elif self.mdfe_modal == "3":
export_dict["any_element"] = self._export_modal_aquaviario()
export_dict["any_element"] = self._export_mdfe_modal_aquaviario()
elif self.mdfe_modal == "4":
export_dict["any_element"] = self._export_modal_ferroviario()
export_dict["any_element"] = self._export_mdfe_modal_ferroviario()

def _export_modal_aereo(self):
if not self.modal_aereo_id:
self.modal_aereo_id = self.modal_aereo_id.create({"document_id": self.id})
def _export_mdfe_modal_aereo(self):
if not self.mdfe_modal_aereo_id:
self.mdfe_modal_aereo_id = self.mdfe_modal_aereo_id.create(
{"document_id": self.id}
)

return self.modal_aereo_id._build_binding("mdfe", "30")
return self.mdfe_modal_aereo_id._build_binding("mdfe", "30")

def _export_modal_ferroviario(self):
if not self.modal_ferroviario_id:
self.modal_ferroviario_id = self.modal_ferroviario_id.create(
def _export_mdfe_modal_ferroviario(self):
if not self.mdfe_modal_ferroviario_id:
self.mdfe_modal_ferroviario_id = self.mdfe_modal_ferroviario_id.create(
{"document_id": self.id}
)

return self.modal_ferroviario_id._build_binding("mdfe", "30")
return self.mdfe_modal_ferroviario_id._build_binding("mdfe", "30")

def _export_modal_aquaviario(self):
if not self.modal_aquaviario_id:
self.modal_aquaviario_id = self.modal_aquaviario_id.create(
def _export_mdfe_modal_aquaviario(self):
if not self.mdfe_modal_aquaviario_id:
self.mdfe_modal_aquaviario_id = self.mdfe_modal_aquaviario_id.create(
{"document_id": self.id}
)

return self.modal_aquaviario_id._build_binding("mdfe", "30")
return self.mdfe_modal_aquaviario_id._build_binding("mdfe", "30")

def _export_modal_rodoviario(self):
if not self.modal_rodoviario_id:
self.modal_rodoviario_id = self.modal_rodoviario_id.create(
def _export_mdfe_modal_rodoviario(self):
if not self.mdfe_modal_rodoviario_id:
self.mdfe_modal_rodoviario_id = self.mdfe_modal_rodoviario_id.create(
{"document_id": self.id}
)

return self.modal_rodoviario_id._build_binding("mdfe", "30")
return self.mdfe_modal_rodoviario_id._build_binding("mdfe", "30")

##########################
# MDF-e tag: seg
Expand Down Expand Up @@ -749,7 +751,7 @@ def _build_attr(self, node, fields, vals, path, attr):
value = getattr(node, attr[0])

# if attr[0] == "any_element": # build modal
# modal_id = self._get_modal_to_build(node.any_element.__module__)
# modal_id = self._get_mdfe_modal_to_build(node.any_element.__module__)
# if modal_id is False:
# return

Expand All @@ -770,12 +772,12 @@ def _build_attr(self, node, fields, vals, path, attr):

return super()._build_attr(node, fields, vals, path, attr)

def _get_modal_to_build(self, module):
def _get_mdfe_modal_to_build(self, module):
modal_by_binding_module = {
self.modal_rodoviario_id._binding_module: self.modal_rodoviario_id,
self.modal_aereo_id._binding_module: self.modal_aereo_id,
self.modal_aquaviario_id._binding_module: self.modal_aquaviario_id,
self.modal_ferroviario_id._binding_module: self.modal_ferroviario_id,
self.mdfe_modal_rodoviario_id._binding_module: self.mdfe_modal_rodoviario_id, # noqa: E501
self.mdfe_modal_aereo_id._binding_module: self.mdfe_modal_aereo_id, # noqa: E501
self.mdfe_modal_aquaviario_id._binding_module: self.mdfe_modal_aquaviario_id, # noqa: E501
self.mdfe_modal_ferroviario_id._binding_module: self.mdfe_modal_ferroviario_id, # noqa: E501
}
if module not in modal_by_binding_module:
return False
Expand Down
Loading