'If current Email Account is default, un-default all other accounts.'

def there_must_be_only_one_default(self):

    for field in (u'default_incoming', u'default_outgoing'):
        if (not self.get(field)):
            continue
        for email_account in frappe.get_all(u'Email    Account', filters={field: 1}):
            if (email_account.name == self.name):
                continue
            email_account = frappe.get_doc(u'Email    Account', email_account.name)
            email_account.set(field, 0)
            email_account.save()
