fix: update onboarding status when lead is converted to deal

This commit is contained in:
Shariq Ansari 2025-03-12 17:20:21 +05:30
parent 73bb4bd9f8
commit 4d74943ebc
3 changed files with 27 additions and 0 deletions

View File

@ -17,3 +17,15 @@ def update_user_onboarding_status(steps: str):
frappe.db.set_value(
"User", frappe.session.user, "onboarding_status", json.dumps(onboarding_status), update_modified=False
)
@frappe.whitelist()
def get_first_non_converted_lead():
lead = frappe.get_all(
"CRM Lead",
filters={"converted": 0},
fields=["name"],
order_by="creation",
limit=1,
)
return lead[0].name if lead else None

View File

@ -49,6 +49,18 @@ const steps = reactive([
title: 'Convert lead to deal',
icon: markRaw(ConvertIcon),
completed: false,
onClick: async () => {
minimize.value = true
let leadName = await call(
'crm.api.onboarding.get_first_non_converted_lead',
)
if (leadName) {
router.push({ name: 'Lead', params: { leadId: leadName } })
} else {
router.push({ name: 'Leads' })
}
},
},
{
name: 'create_first_note',

View File

@ -348,6 +348,7 @@ import {
callEnabled,
isMobileView,
} from '@/composables/settings'
import { useOnboarding } from '@/composables/onboarding'
import { capture } from '@/telemetry'
import {
createResource,
@ -370,6 +371,7 @@ const { isManager } = usersStore()
const { $dialog, $socket, makeCall } = globalStore()
const { getContactByName, contacts } = contactsStore()
const { statusOptions, getLeadStatus, getDealStatus } = statusesStore()
const { updateOnboardingStep } = useOnboarding()
const route = useRoute()
const router = useRouter()
@ -658,6 +660,7 @@ async function convertToDeal(updated) {
})
})
if (_deal) {
updateOnboardingStep('convert_lead_to_deal')
capture('convert_lead_to_deal')
if (updated) {
await contacts.reload()