Skip to content

Commit

Permalink
Merge pull request #26768 from frappe/mergify/bp/version-14-hotfix/pr…
Browse files Browse the repository at this point in the history
…-26758

feat: set the only email address as primary (backport #26758)
  • Loading branch information
barredterra committed Jun 15, 2024
2 parents aa05994 + 53e7792 commit 8d983e2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frappe/contacts/doctype/contact/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def set_primary_email(self):
if len([email.email_id for email in self.email_ids if email.is_primary]) > 1:
frappe.throw(_("Only one {0} can be set as primary.").format(frappe.bold("Email ID")))

if len(self.email_ids) == 1:
self.email_ids[0].is_primary = 1

primary_email_exists = False
for d in self.email_ids:
if d.is_primary == 1:
Expand Down

0 comments on commit 8d983e2

Please sign in to comment.