From f0674ab1befa0461dabd80f26565b87c10fb0fae Mon Sep 17 00:00:00 2001 From: FrankC013 Date: Wed, 16 Oct 2024 14:42:01 +0200 Subject: [PATCH] [FIX] connector_woocommerce: fix duplicated parents partners and improve search and error message of partners --- connector_woocommerce/models/sale_order/import_mapper.py | 2 +- connector_woocommerce/models/sale_order/importer.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/connector_woocommerce/models/sale_order/import_mapper.py b/connector_woocommerce/models/sale_order/import_mapper.py index af3a36b58..3cd7f92b2 100644 --- a/connector_woocommerce/models/sale_order/import_mapper.py +++ b/connector_woocommerce/models/sale_order/import_mapper.py @@ -80,7 +80,7 @@ def payment_method(self, record): payment_mode = self.backend_record.payment_mode_ids.filtered( lambda x: record["payment_method"] == x.woocommerce_payment_mode ) - if not payment_mode: + if not payment_mode and record["payment_method"]: raise ValidationError( _("Payment method '%s' is not defined on backend") % record.get("payment_method") diff --git a/connector_woocommerce/models/sale_order/importer.py b/connector_woocommerce/models/sale_order/importer.py index ce97985b5..9baaa3b43 100644 --- a/connector_woocommerce/models/sale_order/importer.py +++ b/connector_woocommerce/models/sale_order/importer.py @@ -39,7 +39,8 @@ class WooCommerceSaleOrderImporter(Component): def _get_partner_parent_domain(self, dir_type, value): name = value[dir_type].get("company") or value[dir_type].get("name") return [ - ("company_type", "=", "company"), + ("company_type", "in", (False, "company")), + ("child_ids", "!=", False), ("name", "=", name), ] @@ -59,10 +60,10 @@ def _get_partner_parent(self, dir_type, value): **self._additional_partner_parent_fields(value, dir_type), } ) - value[dir_type]["parent"] = parent.id elif len(parent) > 1: raise ValidationError( - _("There are more than one partner with the same name") + _("There are more than one parent partner with the same name %s") + % value[dir_type].get("name") ) value[dir_type]["parent"] = parent.id