Skip to content

Commit

Permalink
feat: add option to update modified on communication recieved (backport
Browse files Browse the repository at this point in the history
#45307) (#45310)

* feat: add option to update modified on communication recieved (#45307)

(cherry picked from commit aa38895)

# Conflicts:
#	erpnext/crm/doctype/crm_settings/crm_settings.json

* chore: resolve conflict

---------

Co-authored-by: Ejaaz Khan <[email protected]>
Co-authored-by: ruthra kumar <[email protected]>
  • Loading branch information
3 people authored Jan 21, 2025
1 parent 96a3a45 commit bf8d6ae
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
19 changes: 16 additions & 3 deletions erpnext/crm/doctype/crm_settings/crm_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"quotation_section",
"default_valid_till",
"section_break_13",
"carry_forward_communication_and_comments"
"carry_forward_communication_and_comments",
"column_break_junk",
"update_timestamp_on_new_communication"
],
"fields": [
{
Expand Down Expand Up @@ -77,21 +79,32 @@
{
"fieldname": "section_break_13",
"fieldtype": "Section Break",
"label": "Other Settings"
"label": "Activity"
},
{
"default": "0",
"description": "All the Comments and Emails will be copied from one document to another newly created document(Lead -> Opportunity -> Quotation) throughout the CRM documents.",
"fieldname": "carry_forward_communication_and_comments",
"fieldtype": "Check",
"label": "Carry Forward Communication and Comments"
},
{
"fieldname": "column_break_junk",
"fieldtype": "Column Break"
},
{
"default": "0",
"description": "Update the modified timestamp on new communications received in Lead & Opportunity.",
"fieldname": "update_timestamp_on_new_communication",
"fieldtype": "Check",
"label": "Update timestamp on new communication"
}
],
"icon": "fa fa-cog",
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2022-06-06 11:22:08.464253",
"modified": "2025-01-16 16:12:14.889455",
"modified_by": "Administrator",
"module": "CRM",
"name": "CRM Settings",
Expand Down
1 change: 1 addition & 0 deletions erpnext/crm/doctype/crm_settings/crm_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CRMSettings(Document):
carry_forward_communication_and_comments: DF.Check
close_opportunity_after_days: DF.Int
default_valid_till: DF.Data | None
update_timestamp_on_new_communication: DF.Check
# end: auto-generated types

def validate(self):
Expand Down
14 changes: 14 additions & 0 deletions erpnext/crm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ def link_communications_with_prospect(communication, method):
row.db_update()


def update_modified_timestamp(communication, method):
if communication.reference_doctype and communication.reference_name:
if communication.sent_or_received == "Received" and frappe.db.get_single_value(
"CRM Settings", "update_timestamp_on_new_communication"
):
frappe.db.set_value(
dt=communication.reference_doctype,
dn=communication.reference_name,
field="modified",
val=now(),
update_modified=False,
)


def get_linked_prospect(reference_doctype, reference_name):
prospect = None
if reference_doctype == "Lead":
Expand Down
5 changes: 4 additions & 1 deletion erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,10 @@
"erpnext.support.doctype.service_level_agreement.service_level_agreement.on_communication_update",
"erpnext.support.doctype.issue.issue.set_first_response_time",
],
"after_insert": "erpnext.crm.utils.link_communications_with_prospect",
"after_insert": [
"erpnext.crm.utils.link_communications_with_prospect",
"erpnext.crm.utils.update_modified_timestamp",
],
},
"Event": {
"after_insert": "erpnext.crm.utils.link_events_with_prospect",
Expand Down

0 comments on commit bf8d6ae

Please sign in to comment.