i have read this Task instead of Project Task!:
i have create a new Doctype “Campionatura” and “Project Campionature” taking inspiration “Task” and “Project Task”
def load_campionature(self):
"""Load `campionature` from the database"""
self.campionature = []
for campionatura in self.get_campionature():
campionatura_map = {
"title": campionatura.subject,
"status": campionatura.status,
"description": campionatura.description,
"campionatura_id": campionatura.name,
"codice_prodotto": campionatura.codice_prodotto
}
self.map_custom_fields(campionatura, campionatura_map)
self.append("campionature", campionatura_map)
def get_campionature(self):
if self.name is None:
return {}
else:
return frappe.get_all("Campionatura", "*", {"project": self.name}, order_by="date asc")
def validate(self):
self.sync_campionature()
self.campionature = []
def sync_campionature(self):
"""sync campionature and remove table"""
if self.flags.dont_sync_campionature: return
campionatura_names = []
for t in self.campionature:
if t.campionatura_id:
campionatura = frappe.get_doc("Campionatura", t.campionatura_id)
else:
campionatura = frappe.new_doc("Campionatura")
campionatura.project = self.name
campionatura.update({
"subject": t.title,
"status": t.status,
"description": t.description,
"codice_prodotto": t.codice_prodotto
})
self.map_custom_fields(t, campionatura)
campionatura.flags.ignore_links = True
campionatura.flags.from_project = True
campionatura.flags.ignore_feed = True
campionatura.save(ignore_permissions = True)
campionatura_names.append(campionatura.name)
# delete
for t in frappe.get_all("Campionatura", ["name"], {"project": self.name, "name": ("not in", campionatura_names)}):
frappe.delete_doc("Campionatura", t.name)
def map_custom_fields(self, source, target):
project_campionatura_custom_fields = frappe.get_all("Custom Field", {"dt": "Project Campionature"}, "fieldname")
for field in project_campionatura_custom_fields:
target.update({
field.fieldname: source.get(field.fieldname)
})
def update_project(self):
self.flags.dont_sync_campionature = True
self.save(ignore_permissions = True)
def on_update(self):
self.load_campionature()
self.sync_campionature()
i have insert this code in
/home/frappe/frappe-bench/apps/erpnext/erpnext/projects/doctype/project.py
Without results
what would be the best way to proceed?