I have created a simple test schedule task. This is the code.
import frappe
def create_device_journal():
# if initial setup not completed, return
if not (frappe.db.a_row_exists("Company") and frappe.db.a_row_exists("Fiscal Year")):
return
_create_device_journal()
def _create_device_journal():
todo = frappe.get_doc({"doctype":"ToDo", "description": "test"})
todo.insert()
# try running the function
create_device_journal()
I want to test it before putting it to erpnext schedule task. I tried running it using python device_journal.py but I got an error
Traceback (most recent call last):
File "device_journal.py", line 22, in <module>
create_device_journal()
File "device_journal.py", line 11, in create_device_journal
if not (frappe.db.a_row_exists("Company") and frappe.db.a_row_exists("Fiscal Year")):
File "/home/chris/frappe-bench/env/local/lib/python2.7/site-packages/werkzeug/local.py", line 342, in __getattr__
return getattr(self._get_current_object(), name)
File "/home/chris/frappe-bench/env/local/lib/python2.7/site-packages/werkzeug/local.py", line 305, in _get_current_object
raise RuntimeError('no object bound to %s' % self.__name__)
RuntimeError: no object bound to db
I think I did not do it right. How do I test the simple task I made?