Skip to content

Commit

Permalink
[FIX] reorder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
felipezago committed Jun 26, 2023
1 parent db0b2c1 commit d9658e6
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions l10n_br_nfe/wizards/import_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
{
Expand Down

0 comments on commit d9658e6

Please sign in to comment.