diff --git a/erpnext/buying/doctype/supplier/supplier_import_provider.py b/erpnext/buying/doctype/supplier/supplier_import_provider.py index 67a152e74b3..fd03c4814ac 100644 --- a/erpnext/buying/doctype/supplier/supplier_import_provider.py +++ b/erpnext/buying/doctype/supplier/supplier_import_provider.py @@ -176,7 +176,10 @@ class SupplierImportProvider(ImportProvider): if flagged or primary is None: primary = address if primary: - frappe.db.set_value("Address", primary.name, "is_primary_address", 1) + # Save (not db.set_value) so Address.validate_preferred_address() clears any + # existing primary address on the party — a raw write would leave two flagged. + primary.is_primary_address = 1 + primary.save() supplier.db_set("supplier_primary_address", primary.name) supplier.db_set("primary_address", get_address_display(primary.name)) diff --git a/erpnext/selling/doctype/customer/customer_import_provider.py b/erpnext/selling/doctype/customer/customer_import_provider.py index 24d5256993f..cc5c7bd230f 100644 --- a/erpnext/selling/doctype/customer/customer_import_provider.py +++ b/erpnext/selling/doctype/customer/customer_import_provider.py @@ -184,7 +184,10 @@ class CustomerImportProvider(ImportProvider): if flagged or primary is None: primary = address if primary: - frappe.db.set_value("Address", primary.name, "is_primary_address", 1) + # Save (not db.set_value) so Address.validate_preferred_address() clears any + # existing primary address on the party — a raw write would leave two flagged. + primary.is_primary_address = 1 + primary.save() customer.db_set("customer_primary_address", primary.name) customer.db_set("primary_address", get_address_display(primary.name))