1
0
forked from test/crm

fix: set lead/deal_owner as assigned user if not set

This commit is contained in:
Shariq Ansari 2024-01-04 19:59:00 +05:30
parent 7fcdd7aaed
commit 54b0bc4e5b
2 changed files with 11 additions and 0 deletions

8
crm/api/todo.py Normal file
View File

@ -0,0 +1,8 @@
import frappe
def after_insert(doc, method):
if doc.reference_type in ["CRM Lead", "CRM Deal"] and doc.reference_name and doc.allocated_to:
fieldname = "lead_owner" if doc.reference_type == "CRM Lead" else "deal_owner"
lead_owner = frappe.db.get_value(doc.reference_type, doc.reference_name, fieldname)
if not lead_owner:
frappe.db.set_value(doc.reference_type, doc.reference_name, fieldname, doc.allocated_to)

View File

@ -129,6 +129,9 @@ doc_events = {
"Contact": {
"validate": ["crm.api.contact.validate"],
},
"ToDo": {
"after_insert": ["crm.api.todo.after_insert"],
},
}
# Scheduled Tasks