Get value from single document

Hello;

I have a document type who is single document and inside it there is a fields that contains values to be used as settings in the module. I need to ready (get) values. How?
I checked the database and did not find these values are stored in the database, so where they are stored?
Below is the picture for this document:

For example: I need to get the value of the field: use discounted rate from trip #, because I need its value to be used in other documents. How?

Actually I need to fetch the value while loading the other document (of course, I can use onload method), but I am not able to fetch the field value and no values stored in the database !
Regards
Bilal

OK. Single Doctype is stored in database in ā€œtabSinglesā€.
And can be called in python using frappe.db.get_single_value or frappe.db.get_value and in my case I used the following:

self.discounted_hop_no = frappe.db.get_single_value(ā€˜Route Pricing Settingsā€™, ā€˜hop_no_discountedā€™)

But really I would like to know the best to deal with settings. If to get its value using frappe.call and by calling a whitelist method or how?

Because settings are always needed in the module and I do not feel it is an efficient way to keep using frappe.call method to get the setting value for each event !

I appreciate if someone can direct me to the best way.
Regards
Bilal

@bghayad I need to get the setting value for some event.
Did you find a way to that?

Hello @Mohammed_Redha
Yes, I used frappe.call (.js) to call the whitelist method (.py) and in the whitelist method I used frappe.db.get_single_value, this is if you need to get always the updated settings. And it depends on what you need to do: You can do this once the document is loaded and you can do this each time you need it in the script.

Regards
Bilal

1 Like