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..f024bbc55 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 partner with the same name %s") + % value[dir_type].get("name") ) value[dir_type]["parent"] = parent.id