-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from shariquerik/status-change-log
feat: Add status change log in Lead/Deal
- Loading branch information
Showing
7 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
78 changes: 78 additions & 0 deletions
78
crm/fcrm/doctype/crm_status_change_log/crm_status_change_log.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [] | ||
} |
27 changes: 27 additions & 0 deletions
27
crm/fcrm/doctype/crm_status_change_log/crm_status_change_log.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}) |