Before everything else, you need to provide your user frappe
all permissions on the frappe-bench folder and all the folders and files inside it. Using this command:
chown -R frappe /home/frappe/frappe-bench
Now you should be able to create files and folders. But I’ll not let you edit the Sales Order python file because that is not the correct way to do it.
Now, since you do have a server, I’ll help you create a new app and you can store your code there.
You can create a new app by executing this command with frappe-bench folder in context
user@pc:~/frappe-bench$ bench new-app any-name-here
Then, install this app on the current site (You can find your currentsite written in the file named sites.txt in folder frappe-bench/sites
).
Assuming your site is named site1.local, and your app name is customapp
user@pc:~/frappe-bench$ bench --site site1.local install-app customapp
This will be over in a matter of seconds because you have no doctype.
Then you can go ahead and make a new folder in path frappe-bench/apps/customapp/customapp/customapp
. You can name your folder validations
and then make a new py file named sales_order.py
Open this github gist and copy the code and paste it in your file:
Github Gist - Sales order Permission Query function
Then in hooks.py, copy and paste this:
permission_query_conditions = {
"Sales Order": "customapp.customapp.validations.sales_call.sales_order.perm_query",
}
Replace word customapp
with your app’s name everywhere. Also, perm_query
is the function’s name that will return the condition string. So if you wish to rename the function to something else such as view_downline_orders
or any relevant names, please be sure to update the same in hooks.py else you will encounter errors.