Merge pull request #863 from shariquerik/convert-to-deal-script
This commit is contained in:
commit
5406f4a11b
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user