Skip to content

Commit

Permalink
feat: set the only email address as primary
Browse files Browse the repository at this point in the history
Some features rely on the Contact having the primary email set. If the Contact has only one email address, we can mark it as primary automatically. Only if there are more than one  addresses available, the user has to choose which one should be set as primary.

(cherry picked from commit be90d55)
  • Loading branch information
barredterra authored and mergify[bot] committed Jun 14, 2024
1 parent aa05994 commit 53e7792
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 53e7792

Please sign in to comment.