From d9658e6242116c289c57d6e4b888c7bcbac57c6e Mon Sep 17 00:00:00 2001 From: Felipe Zago Date: Mon, 26 Jun 2023 10:55:41 -0300 Subject: [PATCH] [FIX] reorder methods --- l10n_br_nfe/wizards/import_document.py | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/l10n_br_nfe/wizards/import_document.py b/l10n_br_nfe/wizards/import_document.py index e7f2eff67f23..619f59ca32fc 100644 --- a/l10n_br_nfe/wizards/import_document.py +++ b/l10n_br_nfe/wizards/import_document.py @@ -94,28 +94,6 @@ def _create_imported_products_by_xml(self, xml): self.imported_products_ids = [(6, 0, product_ids)] - def create_edoc_from_xml(self): - self.set_fiscal_operation_type() - - edoc = self.env["l10n_br_fiscal.document"].import_nfe_xml( - self.parse_xml(), - edoc_type=self.fiscal_operation_type, - ) - self._attach_original_nfe_xml_to_document(edoc) - self.imported_products_ids._create_or_update_product_supplierinfo( - partner_id=edoc.partner_id - ) - - return edoc - - def set_fiscal_operation_type(self): - document = self.get_document_by_xml(self.parse_xml()) - - if document.cnpj_cpf_emitente == self.company_id.cnpj_cpf: - self.fiscal_operation_type = "out" - else: - self.fiscal_operation_type = "in" - def _prepare_imported_product_values(self, product): taxes = self._get_taxes_from_xml_product(product) uom_id = self.env["uom.uom"].search([("code", "=", product.prod.uCom)], limit=1) @@ -162,6 +140,28 @@ def _get_taxes_from_xml_product(self, product): return {"vICMS": vICMS, "pICMS": pICMS, "vIPI": vIPI, "pIPI": pIPI} + def create_edoc_from_xml(self): + self.set_fiscal_operation_type() + + edoc = self.env["l10n_br_fiscal.document"].import_nfe_xml( + self.parse_xml(), + edoc_type=self.fiscal_operation_type, + ) + self._attach_original_nfe_xml_to_document(edoc) + self.imported_products_ids._create_or_update_product_supplierinfo( + partner_id=edoc.partner_id + ) + + return edoc + + def set_fiscal_operation_type(self): + document = self.get_document_by_xml(self.parse_xml()) + + if document.cnpj_cpf_emitente == self.company_id.cnpj_cpf: + self.fiscal_operation_type = "out" + else: + self.fiscal_operation_type = "in" + def _attach_original_nfe_xml_to_document(self, edoc): return self.env["ir.attachment"].create( {