1
0
forked from test/crm

Merge pull request #864 from frappe/mergify/bp/main-hotfix/pr-863

This commit is contained in:
Shariq Ansari 2025-05-26 15:51:58 +05:30 committed by GitHub
commit b3c1ebb24d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -100,7 +100,15 @@ export function useDocument(doctype, docname) {
async function triggerOnCreateLead() {
const args = Array.from(arguments)
const handler = async function () {
await this.on_create_lead(...args)
await this.on_create_lead?.(...args)
}
await trigger(handler)
}
async function triggerConvertToDeal() {
const args = Array.from(arguments)
const handler = async function () {
await this.convert_to_deal?.(...args)
}
await trigger(handler)
}
@ -139,5 +147,6 @@ export function useDocument(doctype, docname) {
triggerOnRefresh,
setupFormScript,
triggerOnCreateLead,
triggerConvertToDeal,
}
}

View File

@ -355,6 +355,7 @@ import { usersStore } from '@/stores/users'
import { globalStore } from '@/stores/global'
import { statusesStore } from '@/stores/statuses'
import { getMeta } from '@/stores/meta'
import { useDocument } from '@/data/document'
import {
whatsappEnabled,
callEnabled,
@ -614,6 +615,8 @@ const existingOrganizationChecked = ref(false)
const existingContact = ref('')
const existingOrganization = ref('')
const { triggerConvertToDeal } = useDocument('CRM Lead', props.leadId)
async function convertToDeal() {
if (existingContactChecked.value && !existingContact.value) {
toast.error(__('Please select an existing contact'))
@ -633,6 +636,12 @@ async function convertToDeal() {
existingOrganization.value = ''
}
await triggerConvertToDeal?.(
lead.data,
deal,
() => (showConvertToDealModal.value = false),
)
let _deal = await call('crm.fcrm.doctype.crm_lead.crm_lead.convert_to_deal', {
lead: lead.data.name,
deal,