Merge pull request #52 from shariquerik/status-change-log
feat: Add status change log in Lead/Deal
This commit is contained in:
commit
43f0b01942
@ -42,7 +42,9 @@
|
||||
"response_by",
|
||||
"column_break_hpvj",
|
||||
"first_response_time",
|
||||
"first_responded_on"
|
||||
"first_responded_on",
|
||||
"log_tab",
|
||||
"status_change_log"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@ -251,11 +253,22 @@
|
||||
"fieldtype": "Data",
|
||||
"label": "Phone",
|
||||
"options": "Phone"
|
||||
},
|
||||
{
|
||||
"fieldname": "log_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Log"
|
||||
},
|
||||
{
|
||||
"fieldname": "status_change_log",
|
||||
"fieldtype": "Table",
|
||||
"label": "Status Change Log",
|
||||
"options": "CRM Status Change Log"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-01-05 16:10:59.595577",
|
||||
"modified": "2024-01-06 14:05:52.669699",
|
||||
"modified_by": "Administrator",
|
||||
"module": "FCRM",
|
||||
"name": "CRM Deal",
|
||||
|
||||
@ -8,6 +8,7 @@ from frappe.desk.form.assign_to import add as assign
|
||||
from frappe.model.document import Document
|
||||
|
||||
from crm.fcrm.doctype.crm_service_level_agreement.utils import get_sla
|
||||
from crm.fcrm.doctype.crm_status_change_log.crm_status_change_log import add_status_change_log
|
||||
|
||||
|
||||
class CRMDeal(Document):
|
||||
@ -20,6 +21,8 @@ class CRMDeal(Document):
|
||||
self.update_organization()
|
||||
if self.deal_owner and not self.is_new():
|
||||
self.assign_agent(self.deal_owner)
|
||||
if self.has_value_changed("status"):
|
||||
add_status_change_log(self)
|
||||
|
||||
def after_insert(self):
|
||||
if self.deal_owner:
|
||||
|
||||
@ -46,7 +46,9 @@
|
||||
"response_by",
|
||||
"column_break_pweh",
|
||||
"first_response_time",
|
||||
"first_responded_on"
|
||||
"first_responded_on",
|
||||
"log_tab",
|
||||
"status_change_log"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@ -84,7 +86,7 @@
|
||||
"options": "Gender"
|
||||
},
|
||||
{
|
||||
"default": "Open",
|
||||
"default": "New",
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
@ -273,12 +275,24 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Territory",
|
||||
"options": "CRM Territory"
|
||||
},
|
||||
{
|
||||
"fieldname": "log_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Log",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "status_change_log",
|
||||
"fieldtype": "Table",
|
||||
"label": "Status Change Log",
|
||||
"options": "CRM Status Change Log"
|
||||
}
|
||||
],
|
||||
"image_field": "image",
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-01-04 21:34:32.388456",
|
||||
"modified": "2024-01-06 13:33:54.744542",
|
||||
"modified_by": "Administrator",
|
||||
"module": "FCRM",
|
||||
"name": "CRM Lead",
|
||||
|
||||
@ -9,6 +9,7 @@ from frappe.model.document import Document
|
||||
|
||||
from frappe.utils import has_gravatar, validate_email_address
|
||||
from crm.fcrm.doctype.crm_service_level_agreement.utils import get_sla
|
||||
from crm.fcrm.doctype.crm_status_change_log.crm_status_change_log import add_status_change_log
|
||||
|
||||
|
||||
class CRMLead(Document):
|
||||
@ -22,6 +23,8 @@ class CRMLead(Document):
|
||||
self.validate_email()
|
||||
if self.lead_owner and not self.is_new():
|
||||
self.assign_agent(self.lead_owner)
|
||||
if self.has_value_changed("status"):
|
||||
add_status_change_log(self)
|
||||
|
||||
def after_insert(self):
|
||||
if self.lead_owner:
|
||||
|
||||
0
crm/fcrm/doctype/crm_status_change_log/__init__.py
Normal file
0
crm/fcrm/doctype/crm_status_change_log/__init__.py
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"creation": "2024-01-06 13:15:31.392201",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"from",
|
||||
"to",
|
||||
"from_date",
|
||||
"to_date",
|
||||
"column_break_mwmz",
|
||||
"duration",
|
||||
"last_status_change_log",
|
||||
"log_owner"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "from",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "From"
|
||||
},
|
||||
{
|
||||
"fieldname": "from_date",
|
||||
"fieldtype": "Datetime",
|
||||
"in_list_view": 1,
|
||||
"label": "From Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "duration",
|
||||
"fieldtype": "Duration",
|
||||
"in_list_view": 1,
|
||||
"label": "Duration"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_mwmz",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "to",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "To"
|
||||
},
|
||||
{
|
||||
"fieldname": "to_date",
|
||||
"fieldtype": "Datetime",
|
||||
"in_list_view": 1,
|
||||
"label": "To Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "last_status_change_log",
|
||||
"fieldtype": "Link",
|
||||
"label": "Last Status Change Log",
|
||||
"options": "CRM Status Change Log"
|
||||
},
|
||||
{
|
||||
"fieldname": "log_owner",
|
||||
"fieldtype": "Link",
|
||||
"label": "Owner",
|
||||
"options": "User"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-01-06 13:26:40.597277",
|
||||
"modified_by": "Administrator",
|
||||
"module": "FCRM",
|
||||
"name": "CRM Status Change Log",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from datetime import datetime
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class CRMStatusChangeLog(Document):
|
||||
pass
|
||||
|
||||
|
||||
def add_status_change_log(doc):
|
||||
if not doc.is_new():
|
||||
last_status_change = doc.status_change_log[-1]
|
||||
last_status_change.to = doc.status
|
||||
last_status_change.to_date = datetime.now()
|
||||
last_status_change.log_owner = frappe.session.user
|
||||
last_status_change.duration = (last_status_change.to_date - last_status_change.from_date).total_seconds()
|
||||
|
||||
doc.append("status_change_log", {
|
||||
"from": doc.status,
|
||||
"to": "",
|
||||
"from_date": datetime.now(),
|
||||
"to_date": "",
|
||||
"log_owner": frappe.session.user,
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user