Re-do of https://github.com/frappe/frappe/pull/12520 Undone by https://github.com/frappe/frappe/pull/12878 Changes done to reflect current state of version-13 Co-authored-by: Suraj Shetty <surajshetty3416@gmail.com>