Hello all
I’m trying to download an import template using the
frappe.core.doctype.data_import.data_import.download_template
RPC method. But for some reason I keep getting this error
AttributeError: 'NoneType' object has no attribute 'items'
I’m trying these invocations
bench execute frappe.core.doctype.data_import.data_import.download_template --args ‘[“User”]’
bench execute frappe.core.doctype.data_import.data_import.download_template --kwargs ‘{“doctype”:“User”}’
Referring to the list of RPC methods by @revant_one at Frappe ERPNext Whitelisted endpoints https://discuss.erpnext.com/t/rest-api-list-of-whitelisted-endpoints/58516 · GitHub I also notice that the download_template has no definition of it’s arguments, unlike all the other methods.
try:
i = Importer(data_import.reference_doctype, data_import=data_import)
i.import_data()
except Exception:
frappe.db.rollback()
data_import.db_set("status", "Error")
data_import.log_error("Data import failed")
finally:
frappe.flags.in_import = False
frappe.publish_realtime("data_import_refresh", {"data_import": data_import.name})
@frappe.whitelist()
def download_template(
doctype, export_fields=None, export_records=None, export_filters=None, file_type="CSV"
):
"""
Download template from Exporter
:param doctype: Document Type
:param export_fields=None: Fields to export as dict {'Sales Invoice': ['name', 'customer'], 'Sales Invoice Item': ['item_code']}
Here is the actual code. Pass the parameters accordingly.
Thanks @rtdany10
Yes I tried passing additional parameters as per this function definition. However only the doctype is mandatory. Even so, I still get the same error. Can you execute this bench command?
Not sure if you can run it through bench, doesn’t it return a CSV file? Try running it through a browser.
Ran using frappe.call, same error.
Here is the log.
Will try to debug once I’m free.