Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions frontend/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ declare module 'vue' {
RightSideLayoutIcon: typeof import('./src/components/Icons/RightSideLayoutIcon.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Search: typeof import('./src/components/Controls/Search.vue')['default']
SearchPopover: typeof import('./src/components/SearchPopover.vue')['default']
Section: typeof import('./src/components/Section.vue')['default']
SectionFields: typeof import('./src/components/SectionFields.vue')['default']
SelectIcon: typeof import('./src/components/Icons/SelectIcon.vue')['default']
Expand Down
18 changes: 0 additions & 18 deletions frontend/src/pages/Opportunity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -930,10 +930,6 @@ function updateField(name, value, callback) {
return;
}

if (isStatusField && opportunity.data[name] != value) {
createChecklist(value)
}

updateOpportunity(name, value, () => {
opportunity.data[name] = value;
callback?.();
Expand All @@ -953,20 +949,6 @@ function updateField(name, value, callback) {
}
}

function createChecklist(value) {
call('next_crm.api.opportunity.create_checklist', {
docname: props.opportunityId,
status: value,
}).catch((err) => {
createToast({
title: __('Error creating checklist'),
text: __(err.messages?.[0]),
icon: 'x',
iconClasses: 'text-ink-red-4',
})
})
}

function onMSAClosed() {
showMSAModal.value = false;
showCreateProjectModal.value = true;
Expand Down
9 changes: 5 additions & 4 deletions next_crm/api/opportunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ def declare_enquiry_lost_api(


@frappe.whitelist()
def create_checklist(docname, status=None):
if not status:
def create_checklist(docname, field=None, value=None):
if not field and not value:
return

parenttype = "CRM Deal Status" if field == "status" else "Sales Stage"
checklist_items = frappe.get_all(
"Opportunity Status Checklist",
filters={"parent": status, "parenttype": "CRM Deal Status"},
filters={"parent": value, "parenttype": parenttype},
fields=["checklist_item"],
pluck="checklist_item",
)
Expand All @@ -65,7 +66,7 @@ def create_checklist(docname, status=None):
todo = frappe.get_doc(
{
"doctype": "ToDo",
"custom_title": _("Checklist for {0}").format(status),
"custom_title": _("Checklist for {0}").format(value),
"description": content,
"reference_type": "Opportunity",
"reference_name": docname,
Expand Down
14 changes: 14 additions & 0 deletions next_crm/doc_events/opportunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
from next_crm.doc_events.utils import delete_attachments_from_crm_notes


def before_save(doc, method=None):
current_status = frappe.db.get_value("Opportunity", doc.name, "status")
current_stage = frappe.db.get_value("Opportunity", doc.name, "sales_stage")
if not current_status and not current_stage:
return

from next_crm.api.opportunity import create_checklist

if doc.status != current_status:
create_checklist(doc.name, field="status", value=doc.status)
if doc.sales_stage != current_stage:
create_checklist(doc.name, field="sales_stage", value=doc.sales_stage)


def on_trash(doc, method=None):
frappe.db.delete("Prospect Opportunity", filters={"opportunity": doc.name})
frappe.db.delete(
Expand Down
57 changes: 57 additions & 0 deletions next_crm/fixtures/custom_field.json
Original file line number Diff line number Diff line change
Expand Up @@ -3019,5 +3019,62 @@
"translatable": 0,
"unique": 0,
"width": null
},
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"doctype": "Custom Field",
"dt": "Sales Stage",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "custom_checklist",
"fieldtype": "Table",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "stage_name",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Checklist",
"length": 0,
"link_filters": null,
"mandatory_depends_on": null,
"modified": "2025-08-26 13:58:10.455205",
"module": "NCRM",
"name": "Sales Stage-custom_checklist",
"no_copy": 0,
"non_negative": 0,
"options": "Opportunity Status Checklist",
"permlevel": 0,
"placeholder": null,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"show_dashboard": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
}
]
5 changes: 4 additions & 1 deletion next_crm/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@
"User": {
"before_validate": ["next_crm.doc_events.user.before_validate"],
},
"Opportunity": {"on_trash": ["next_crm.doc_events.opportunity.on_trash"]},
"Opportunity": {
"on_trash": ["next_crm.doc_events.opportunity.on_trash"],
"before_save": ["next_crm.doc_events.opportunity.before_save"],
},
"Notification Log": {
"before_save": ["next_crm.doc_events.notification_log.before_save"],
},
Expand Down