From 41888714b321ae018cee842a24710b7c494ce485 Mon Sep 17 00:00:00 2001 From: Tiago Amaral Date: Thu, 24 Oct 2024 10:41:28 -0300 Subject: [PATCH] [IMP] l10n_br_cnpj_search: default_get from res.partner --- .../wizard/partner_cnpj_search_wizard.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/l10n_br_cnpj_search/wizard/partner_cnpj_search_wizard.py b/l10n_br_cnpj_search/wizard/partner_cnpj_search_wizard.py index 72fbdf06c70d..d7b2d36d24de 100644 --- a/l10n_br_cnpj_search/wizard/partner_cnpj_search_wizard.py +++ b/l10n_br_cnpj_search/wizard/partner_cnpj_search_wizard.py @@ -84,12 +84,13 @@ def _get_partner_values(self, cnpj_cpf): def default_get(self, fields): res = super().default_get(fields) partner_id = self.env.context.get("default_partner_id") - partner_model = self.env["res.partner"] - partner = partner_model.browse(partner_id) - cnpj_cpf = punctuation_rm(partner.cnpj_cpf) - misc.punctuation_rm(self.zip) - values = self._get_partner_values(cnpj_cpf) - res.update(values) + if partner_id: + partner_model = self.env["res.partner"] + partner = partner_model.browse(partner_id) + cnpj_cpf = punctuation_rm(partner.cnpj_cpf) + misc.punctuation_rm(self.zip) + values = self._get_partner_values(cnpj_cpf) + res.update(values) return res def action_update_partner(self):