I am trying to use a Python file to change records on ERPNext but am not able to connect to the currentsite. As advised on this link below :
I used frappe.init() and frappe.connect() but I get this error traceback (local python environment is activated)
Traceback (most recent call last):
File "apps/erpnext/erpnext/stock/doctype/serial_no/serial_patch_warehouse.py", line 103, in <module>
frappe.init("/home/user/frappe-bench/sites/site1.local")
File "/home/user/frappe-bench/apps/frappe/frappe/__init__.py", line 158, in init
setup_module_map()
File "/home/user/frappe-bench/apps/frappe/frappe/__init__.py", line 853, in setup_module_map
for app in get_all_apps(True):
File "/home/user/frappe-bench/apps/frappe/frappe/__init__.py", line 737, in get_all_apps
apps = get_file_items(os.path.join(sites_path, "apps.txt"), raise_not_found=True)
File "/home/user/frappe-bench/apps/frappe/frappe/__init__.py", line 869, in get_file_items
content = read_file(path, raise_not_found=raise_not_found)
File "/home/user/frappe-bench/apps/frappe/frappe/__init__.py", line 891, in read_file
raise IOError("{} Not Found".format(path))
IOError: ./apps.txt Not Found
Here is how I have used these two here:
def execute():
"""
Interface for executing patch
"""
data = []
frappe.init("/home/user/frappe-bench/sites/site1.local")
frappe.connect("/home/user/frappe-bench/sites/site1.local")
data = get_data(warehouse_script)
clean_location(data)
frappe.db.commit()
I used the entire path because previously when I would mention site1.local
it just wouldn’t run and throw an error that site1.local does not exist
. What am I doing wrong here ?
EDIT : I was able to run the script by navigating to the sites folder and apps.txt was present there.