Hi there,
I’m experimenting with Virtual DocType and I’m stuck just a few steps before reaching my goal.
I’m trying to populate this Virtual DocType with some data:
This is my controller:
class SchluesselVirtual(Document):
def db_insert(self):
pass
def load_from_db(self):
print("load_from_db")
print(self)
def db_update(self):
pass
def get_list(self, args):
result = get_data()
print("get_list")
print(result)
return result
def get_data():
# return [{"nummer" : "123", "bezeichnung": "OneTwoThree"}, {"nummer" : "456", "bezeichnung": "FourFiveSix"}]
return frappe.db.sql("select distinct bezeichnung, nummer from tabSchluessel", as_dict=1)
As you can see I tried to provide some data as a dictionary but then settled for a sql-query as a data source. There is the same problem with both ways.
Unfortunately the List View is not populated with the data. There is also some strange error in the console window:
These errors don’t appear when displaying normal DocTypes.
The log looks quite normal to me:
17:01:02 web.1 | 127.0.0.1 - - [02/Nov/2021 17:01:02] "GET /api/method/frappe.desk.reportview.get_sidebar_stats?stats=%5B%22_user_tags%22%5D&doctype=Schluessel&filters=%5B%5D&_=1635867960301 HTTP/1.1" 200 -
17:02:59 web.1 | load_from_db
17:02:59 web.1 | SchluesselVirtual(Schluessel Virtual)
17:02:59 web.1 | get_list
17:02:59 web.1 | [{'bezeichnung': 'Garage', 'nummer': '123'}, {'bezeichnung': 'Wohnungstür', 'nummer': 'ABC'}, {'bezeichnung': 'Haustür', 'nummer': 'XYZ'}]
17:02:59 web.1 | 127.0.0.1 - - [02/Nov/2021 17:02:59] "POST /api/method/frappe.desk.reportview.get HTTP/1.1" 200 -
I think there is something missing in the controller. Can anyone help me out?