How to allow a custom Desk Theme (Modern_ui_theme) when saving Email Account in ERPNext?

Hi everyone,

I’m developing a custom app and I want to use a custom Desk Theme called Modern_ui_theme.

By default, Frappe only allows the following desk themes:

  • Light
  • Dark
  • Automatic

:white_check_mark: What I’ve done so far

  1. Overrode switch_theme method so users can select Modern_ui_theme:
# hooks.py
override_whitelisted_methods = {
    "frappe.core.doctype.user.user.switch_theme": "novasource.override.theme_override.switch_theme"
}
# theme_override.py
import frappe

@frappe.whitelist()
def switch_theme(theme):
    if theme in ["Dark", "Light", "Automatic", "Modern_ui_theme"]:
        frappe.db.set_value("User", frappe.session.user, "desk_theme", theme)

This works fine when switching themes interactively.

  1. User creation and System Settings update also work fine — no validation issues there.

:cross_mark: The problem

I only face the following error when saving Email Account setup:

Desk Theme cannot be "Modern_ui_theme". It should be one of "Light", "Dark", "Automatic".

It seems like the Email Account process indirectly validates the desk_theme of the current user.


:red_question_mark: My Question

Is there a more elegant way to allow "Modern_ui_theme" globally, so that it doesn’t break when saving Email Account?

  • I don’t want to modify Frappe/ERPNext core.
  • I want to keep all other validations intact.
  • Ideally, I’d like to extend the allowed desk themes list in one central place, instead of patching multiple doctypes.

I experienced the same thing and realized customizing the Frappe UI is pretty limited. Our team eventually abandoned the override approach and found a workaround via a custom app Hoot Theme. The app is a fork of Owl Theme and we developed it further to extend its features. The app is purely JS so it’s not invasive. If you’re open to an alternative approach, please give it a try and let us know what you think.

We made sure to make customization as free and flexible as possible. We have a bunch of personalization options like coloring the form fields, the navbar, searchbar, sidebar, etc. We also have the Auto-Theme feature that generates a color palette based on an accent color.

Seems great! This works in V16?