From 4205c9fe0b82290cecc835a79e3b670f03e40587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Sun, 29 Sep 2024 15:12:59 +0000 Subject: [PATCH] [REF] l10n_br_nfe: cnpj_cpf is now a related of vat --- l10n_br_nfe/models/dfe.py | 4 ++-- l10n_br_nfe/models/res_partner.py | 4 ++-- l10n_br_nfe/wizards/import_document.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/l10n_br_nfe/models/dfe.py b/l10n_br_nfe/models/dfe.py index 1a9d85aecfd2..00fa17ddbd30 100644 --- a/l10n_br_nfe/models/dfe.py +++ b/l10n_br_nfe/models/dfe.py @@ -55,7 +55,7 @@ def _create_mde_from_procNFe(self, root): return mde_id supplier_cnpj = utils.mask_cnpj("%014d" % root.NFe.infNFe.emit.CNPJ) - partner = self.env["res.partner"].search([("cnpj_cpf", "=", supplier_cnpj)]) + partner = self.env["res.partner"].search([("vat", "=", supplier_cnpj)]) return self.env["l10n_br_nfe.mde"].create( { @@ -87,7 +87,7 @@ def _create_mde_from_resNFe(self, root): return mde_id supplier_cnpj = utils.mask_cnpj("%014d" % root.CNPJ) - partner_id = self.env["res.partner"].search([("cnpj_cpf", "=", supplier_cnpj)]) + partner_id = self.env["res.partner"].search([("vat", "=", supplier_cnpj)]) return self.env["l10n_br_nfe.mde"].create( { diff --git a/l10n_br_nfe/models/res_partner.py b/l10n_br_nfe/models/res_partner.py index bd1eab67c08a..003ffc8c5c66 100644 --- a/l10n_br_nfe/models/res_partner.py +++ b/l10n_br_nfe/models/res_partner.py @@ -303,8 +303,8 @@ def match_or_create_m2o(self, rec_dict, parent_dict, model=None): if rec_dict.get("cnpj_cpf", False): domain_cnpj = [ "|", - ("cnpj_cpf", "=", rec_dict["cnpj_cpf"]), - ("cnpj_cpf", "=", cnpj_cpf.formata(rec_dict["cnpj_cpf"])), + ("cnpj_cpf_stripped", "=", rec_dict["cnpj_cpf"]), + ("vat", "=", cnpj_cpf.formata(rec_dict["cnpj_cpf"])), ] match = self.search(domain_cnpj, limit=1) if match: diff --git a/l10n_br_nfe/wizards/import_document.py b/l10n_br_nfe/wizards/import_document.py index 43de26d3c66d..40dbcdf81ccb 100644 --- a/l10n_br_nfe/wizards/import_document.py +++ b/l10n_br_nfe/wizards/import_document.py @@ -63,7 +63,7 @@ def _fill_wizard_from_binding(self): self.partner_id = self.env["res.partner"].search( [ "|", - ("cnpj_cpf", "=", infNFe.emit.CNPJ), + ("vat", "=", infNFe.emit.CNPJ), ("nfe40_xNome", "=", infNFe.emit.xNome), ], limit=1,