ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

__islocal for Single doctype


#1

Hi,

The case is:
I want to fill the default value for some fields in the Settings (any settings page/form) which originally (when create new-site) are empty.
But the field may be changed later by user.

So my problems are:

  1. How to check if the field is empty because it is original or because it is intended to be empty by user.
    I know that to check if a doc is saved or not we can use __islocal.
    But it seems it can’t be used to check the status of singles doctype. Is there any equivalent to __islocal for Singles?

  2. What trigger for the method to set_value should I use?
    I can use refresh, onload, or setup if I can check the status of the single doctype. Otherwise it always back to the set_value value when the page is reloaded.
    I’m thinking of something equivalent to after_install so only set once.

Thank you