Virtual DocType: AttributeError: type object 'Document' has no attribute 'get_list'

I am trying to create a Virtual DocType in a Frappe app. The Frappe documentation was not very helpful at all…

The data is populated by an api call to …postgrid.api.list_bank_accounts which returns json from Postgrid. I verified that the api call itself work.

However, when I go to the List View page for the virtual doctype, I get the error.

import frappe
from frappe.model.document import Document
from postalmail.postgrid import api as postgridapi

class PostgridBankAccount(Document):
    def get_list(args):
        # Fetch data from the PostGrid API
            response = postgridapi.list_bank_accounts()
            # Ensure the response has the expected structure
            if response and 'message' in response and 'data' in response['message']:
                accounts_list = response['message']['data']
                accounts_list = []

            # Format the list for Frappe
            formatted_accounts = []
            for account in accounts_list:
                formatted_account = {
                    'name': str(account.get('id')),  # Use account ID as the name
                    'object': account.get('object'),
                    'live': account.get('live'),
                    'accountNumberAndIDSHA256': account.get('accountNumberAndIDSHA256'),
                    'accountNumberLast4': account.get('accountNumberLast4'),
                    'bankCountryCode': account.get('bankCountryCode'),
                    'bankName': account.get('bankName'),
                    'bankPrimaryLine': account.get('bankPrimaryLine'),
                    'bankSecondaryLine': account.get('bankSecondaryLine', ''),
                    'description': account.get('description', ''),
                    'routingNumber': account.get('routingNumber'),
                    'signatureImage': account.get('signatureImage'),
                    'createdAt': account.get('createdAt'),
                    'updatedAt': account.get('updatedAt')

            return formatted_accounts
        except Exception as e:
            frappe.log_error(frappe.get_traceback(), "PostGrid API Error")
            return []

Hi @oguruma

Check how this is made:

Hope this helps.

Thanks for pointing me in the right direction, but I’m afraid I still don’t get it…

What exactly should get_list return?