DocType that is Virtual OR non-virtual?

I know there is a setting in doctype.json for is_virtual, but I am curious if it’s possible to have a DocType that can be virtual or non-virtual based on a setting in the app.

For instance, suppose the I want to give the user option to set the custom doctype to either get the data via API (a virtual doctype) or to actually have the data live in their Frappe database (non virtual doctype).

If the DocType is set to non-virtual, then a scheduler task will run to manually import the data into the database. If they set it to virtual, then the data won’t be imported and the data will be fetched via API.

2 Likes

Hi there,

I think one way to do this would be to have three documents: the virtual one, the non-virtual one, and then a third virtual one that interpolates the data of the other two programmatically.

But, to answer your question, no, I don’t think it’s possible to switch back and forth. I think it’d be tricky to implement that feature in a safe and effective way.