Hi,
I’ve two Doctypes named Project(built-in) & Complain Box (Custom in HR Module)
I’ve a field in Complain Box named ‘project_name’
I need whenever Complain Box is saved it should create new Project automatically,
I tried,
PY
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class Complain():
@frappe.whitelist()
def create_project(project_name):
doc = frappe.new_doc("Project")
doc.save()
frappe.db.commit()
return doc.name
But this giving an error when i am saving the Complain Box “The Resource you are looking for is not available”
I don’t know much how to code in python, but i am willing to learn, can someone please help me out to achieve this?
Which path should i put here?
Currently i’ve given the where the form should be created, means i want to create a new project so i gave the Project’s path.
Second thing, i created the python file in Complain Box’s folder, is it correct? Or it should be created in Project folder?
This depends on where your “Complain” doctype is located.
Assuming you have your app “yourapp”, your python file should be located in /home/frappe/frappe-bench/apps/yourapp/yourapp/yourapp/doctype/compain/complain.py. With the method name being def create_project, that would give you a command
But the above method is inserting Project name with giving name, “My New Project”,
Not with the value of project_name field in Complain box.
Can you please tell me how should i transfer value from complain box to Project like project_name etc?
And the second thing is, Project is inserting only when i execute method from bench,
not when i save Complain Box.
The old error is still there "The resource you are looking for is not available"
@lasalesi
Yes that was parameter’s issue. (fixed)
& yes that was permission issue,
is there any way that my function could be able to ignore permissions?