feat: Prospect
This commit is contained in:
parent
44434ff70f
commit
4a529f8039
@ -51,7 +51,7 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
|
|||||||
|
|
||||||
make_customer () {
|
make_customer () {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.crm.doctype.lead.lead.make_customer",
|
method: "erpnext.crm.doctype.lead.lead.make_prospect",
|
||||||
frm: cur_frm
|
frm: cur_frm
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,16 @@ class Lead(SellingController):
|
|||||||
|
|
||||||
return contact
|
return contact
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_prospect(source_name, target_doc=None, leads=None):
|
||||||
|
print("``````````````````````````")
|
||||||
|
print(source_name)
|
||||||
|
print("``````````````````````````")
|
||||||
|
print(target_doc)
|
||||||
|
print("``````````````````````````")
|
||||||
|
print(leads)
|
||||||
|
print("``````````````````````````")
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_customer(source_name, target_doc=None):
|
def make_customer(source_name, target_doc=None):
|
||||||
return _make_customer(source_name, target_doc)
|
return _make_customer(source_name, target_doc)
|
||||||
|
36
erpnext/crm/doctype/lead/lead_list.js
Normal file
36
erpnext/crm/doctype/lead/lead_list.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
frappe.listview_settings['Lead'] = {
|
||||||
|
onload: function(listview) {
|
||||||
|
if (frappe.boot.user.can_create.includes("Prospect")) {
|
||||||
|
listview.page.add_action_item(__("Create Prospect"), function() {
|
||||||
|
let leads = listview.get_checked_items();
|
||||||
|
console.log(listview.get_checked_items());
|
||||||
|
frappe.model.open_mapped_doc({
|
||||||
|
method: "erpnext.crm.doctype.lead.lead.make_prospect",
|
||||||
|
frm: cur_frm,
|
||||||
|
leads: leads
|
||||||
|
})
|
||||||
|
|
||||||
|
// listview.call_for_selected_items(method, {"status": "Open"});
|
||||||
|
// let prospect_lead = []
|
||||||
|
// leads.forEach(lead => {
|
||||||
|
// prospect_lead.push({
|
||||||
|
// "lead": lead.name
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// console.log("check");
|
||||||
|
// console.log(prospect_lead);
|
||||||
|
// frappe.new_doc("Prospect", {
|
||||||
|
// "company_name": leads[0].company_name,
|
||||||
|
// "industry": leads[0].industry,
|
||||||
|
// "market_segment": leads[0].market_segment,
|
||||||
|
// "territory": leads[0].territory,
|
||||||
|
// "no_of_employees": leads[0].no_of_employees,
|
||||||
|
// "fax": leads[0].fax,
|
||||||
|
// "website": leads[0].website,
|
||||||
|
// "prospect_owner": leads[0].lead_owner,
|
||||||
|
// "prospect_lead": prospect_lead
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@ -10,15 +10,7 @@ frappe.ui.form.on("Opportunity", {
|
|||||||
frm.custom_make_buttons = {
|
frm.custom_make_buttons = {
|
||||||
'Quotation': 'Quotation',
|
'Quotation': 'Quotation',
|
||||||
'Supplier Quotation': 'Supplier Quotation'
|
'Supplier Quotation': 'Supplier Quotation'
|
||||||
},
|
};
|
||||||
|
|
||||||
frm.set_query("opportunity_from", function() {
|
|
||||||
return{
|
|
||||||
"filters": {
|
|
||||||
"name": ["in", ["Customer", "Lead"]],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (frm.doc.opportunity_from && frm.doc.party_name){
|
if (frm.doc.opportunity_from && frm.doc.party_name){
|
||||||
frm.trigger('set_contact_link');
|
frm.trigger('set_contact_link');
|
||||||
|
@ -78,13 +78,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "opportunity_from",
|
"fieldname": "opportunity_from",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Select",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Opportunity From",
|
"label": "Opportunity From",
|
||||||
"oldfieldname": "enquiry_from",
|
"oldfieldname": "enquiry_from",
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"options": "DocType",
|
"options": "\nLead\nProspect\nCustomer",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
@ -430,7 +430,7 @@
|
|||||||
"icon": "fa fa-info-sign",
|
"icon": "fa fa-info-sign",
|
||||||
"idx": 195,
|
"idx": 195,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-04 10:11:22.831139",
|
"modified": "2021-08-23 14:43:09.484227",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "CRM",
|
"module": "CRM",
|
||||||
"name": "Opportunity",
|
"name": "Opportunity",
|
||||||
|
0
erpnext/crm/doctype/prospect/__init__.py
Normal file
0
erpnext/crm/doctype/prospect/__init__.py
Normal file
39
erpnext/crm/doctype/prospect/prospect.js
Normal file
39
erpnext/crm/doctype/prospect/prospect.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Prospect', {
|
||||||
|
refresh () {
|
||||||
|
if (!cur_frm.is_new() && frappe.boot.user.can_create.includes("Customer")) {
|
||||||
|
cur_frm.add_custom_button(__("Customer"), function() {
|
||||||
|
frappe.model.open_mapped_doc({
|
||||||
|
method: "erpnext.crm.doctype.prospect.prospect.make_customer",
|
||||||
|
frm: cur_frm
|
||||||
|
})
|
||||||
|
}, __("Create"));
|
||||||
|
}
|
||||||
|
if (!cur_frm.is_new() && frappe.boot.user.can_create.includes("Opportunity")) {
|
||||||
|
cur_frm.add_custom_button(__("Opportunity"), function() {
|
||||||
|
frappe.model.open_mapped_doc({
|
||||||
|
method: "erpnext.crm.doctype.prospect.prospect.make_opportunity",
|
||||||
|
frm: cur_frm
|
||||||
|
})
|
||||||
|
}, __("Create"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
make_customer () {
|
||||||
|
console.log("Make Customer");
|
||||||
|
frappe.model.open_mapped_doc({
|
||||||
|
method: "erpnext.crm.doctype.prospect.prospect.make_customer",
|
||||||
|
frm: cur_frm
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
make_opportunity () {
|
||||||
|
console.log("Make Opportunity");
|
||||||
|
// frappe.model.open_mapped_doc({
|
||||||
|
// method: "erpnext.crm.doctype.lead.lead.make_opportunity",
|
||||||
|
// frm: cur_frm
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
});
|
165
erpnext/crm/doctype/prospect/prospect.json
Normal file
165
erpnext/crm/doctype/prospect/prospect.json
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"autoname": "field:company_name",
|
||||||
|
"creation": "2021-08-19 00:21:06.995448",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"company_name",
|
||||||
|
"industry",
|
||||||
|
"market_segment",
|
||||||
|
"customer_group",
|
||||||
|
"territory",
|
||||||
|
"column_break_6",
|
||||||
|
"no_of_employees",
|
||||||
|
"currency",
|
||||||
|
"annual_revenue",
|
||||||
|
"fax",
|
||||||
|
"website",
|
||||||
|
"prospect_owner",
|
||||||
|
"leads_section",
|
||||||
|
"prospect_lead",
|
||||||
|
"addresses_and_contacts_section",
|
||||||
|
"address_html",
|
||||||
|
"column_break_17",
|
||||||
|
"contact_html",
|
||||||
|
"notes_section",
|
||||||
|
"notes"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "company_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Company Name",
|
||||||
|
"unique": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "industry",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Industry",
|
||||||
|
"options": "Industry Type"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "market_segment",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Market Segment",
|
||||||
|
"options": "Market Segment"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "customer_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Customer Group",
|
||||||
|
"options": "Customer Group"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "territory",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Territory",
|
||||||
|
"options": "Territory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_6",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "no_of_employees",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "No. of Employees"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "currency",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Currency",
|
||||||
|
"options": "Currency"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "annual_revenue",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Annual Revenue",
|
||||||
|
"options": "currency"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fax",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Fax",
|
||||||
|
"options": "Phone"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "website",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Website",
|
||||||
|
"options": "URL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "prospect_owner",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Prospect Owner",
|
||||||
|
"options": "User"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "leads_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Leads"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "prospect_lead",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"options": "Prospect Lead"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval: !doc.__islocal",
|
||||||
|
"fieldname": "addresses_and_contacts_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Addresses and Contacts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "address_html",
|
||||||
|
"fieldtype": "HTML",
|
||||||
|
"label": "Address HTML"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_17",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "contact_html",
|
||||||
|
"fieldtype": "HTML",
|
||||||
|
"label": "Contact HTML"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"collapsible": 1,
|
||||||
|
"fieldname": "notes_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Notes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "notes",
|
||||||
|
"fieldtype": "Text Editor"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-08-19 00:29:00.767038",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "CRM",
|
||||||
|
"name": "Prospect",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
45
erpnext/crm/doctype/prospect/prospect.py
Normal file
45
erpnext/crm/doctype/prospect/prospect.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
|
class Prospect(Document):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_customer(source_name, target_doc=None):
|
||||||
|
def set_missing_values(source, target):
|
||||||
|
target.customer_type = "Company"
|
||||||
|
target.company_name = source.name
|
||||||
|
target.customer_group = source.customer_group or frappe.db.get_default("Customer Group")
|
||||||
|
|
||||||
|
doclist = get_mapped_doc("Prospect", source_name,
|
||||||
|
{"Prospect": {
|
||||||
|
"doctype": "Customer",
|
||||||
|
"field_map": {
|
||||||
|
"company_name": "customer_name",
|
||||||
|
"currency": "default_currency",
|
||||||
|
"fax": "fax"
|
||||||
|
}
|
||||||
|
}}, target_doc, set_missing_values, ignore_permissions=False)
|
||||||
|
|
||||||
|
return doclist
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_opportunity(source_name, target_doc=None):
|
||||||
|
def set_missing_values(source, target):
|
||||||
|
target.opportunity_from = "Prospect"
|
||||||
|
target.customer_name = source.company_name
|
||||||
|
target.customer_group = source.customer_group or frappe.db.get_default("Customer Group")
|
||||||
|
|
||||||
|
doclist = get_mapped_doc("Prospect", source_name,
|
||||||
|
{"Prospect": {
|
||||||
|
"doctype": "Opportunity",
|
||||||
|
"field_map": {
|
||||||
|
"name": "party_name",
|
||||||
|
}
|
||||||
|
}}, target_doc, set_missing_values, ignore_permissions=False)
|
||||||
|
|
||||||
|
return doclist
|
8
erpnext/crm/doctype/prospect/test_prospect.py
Normal file
8
erpnext/crm/doctype/prospect/test_prospect.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestProspect(unittest.TestCase):
|
||||||
|
pass
|
0
erpnext/crm/doctype/prospect_lead/__init__.py
Normal file
0
erpnext/crm/doctype/prospect_lead/__init__.py
Normal file
71
erpnext/crm/doctype/prospect_lead/prospect_lead.json
Normal file
71
erpnext/crm/doctype/prospect_lead/prospect_lead.json
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-08-19 00:14:14.857421",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"lead",
|
||||||
|
"lead_name",
|
||||||
|
"status",
|
||||||
|
"email",
|
||||||
|
"mobile_no"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "lead",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Lead",
|
||||||
|
"options": "Lead",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "lead.lead_name",
|
||||||
|
"fetch_if_empty": 1,
|
||||||
|
"fieldname": "lead_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Lead Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "lead.status",
|
||||||
|
"fetch_if_empty": 1,
|
||||||
|
"fieldname": "status",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Status",
|
||||||
|
"options": "Lead\nOpen\nReplied\nOpportunity\nQuotation\nLost Quotation\nInterested\nConverted\nDo Not Contact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "lead.email_id",
|
||||||
|
"fetch_if_empty": 1,
|
||||||
|
"fieldname": "email",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Email",
|
||||||
|
"options": "Email"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "lead.mobile_no",
|
||||||
|
"fetch_if_empty": 1,
|
||||||
|
"fieldname": "mobile_no",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Mobile No",
|
||||||
|
"options": "Phone"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-08-20 01:58:39.387874",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "CRM",
|
||||||
|
"name": "Prospect Lead",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
8
erpnext/crm/doctype/prospect_lead/prospect_lead.py
Normal file
8
erpnext/crm/doctype/prospect_lead/prospect_lead.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class ProspectLead(Document):
|
||||||
|
pass
|
@ -20,6 +20,7 @@
|
|||||||
"tax_withholding_category",
|
"tax_withholding_category",
|
||||||
"default_bank_account",
|
"default_bank_account",
|
||||||
"lead_name",
|
"lead_name",
|
||||||
|
"prospect",
|
||||||
"image",
|
"image",
|
||||||
"column_break0",
|
"column_break0",
|
||||||
"account_manager",
|
"account_manager",
|
||||||
@ -212,8 +213,7 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"ignore_user_permissions": 1,
|
"ignore_user_permissions": 1,
|
||||||
"label": "Represents Company",
|
"label": "Represents Company",
|
||||||
"options": "Company",
|
"options": "Company"
|
||||||
"unique": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "represents_company",
|
"depends_on": "represents_company",
|
||||||
@ -493,6 +493,12 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Tax Withholding Category",
|
"label": "Tax Withholding Category",
|
||||||
"options": "Tax Withholding Category"
|
"options": "Tax Withholding Category"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "prospect",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Prospect",
|
||||||
|
"options": "Prospect"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-user",
|
"icon": "fa fa-user",
|
||||||
@ -500,7 +506,7 @@
|
|||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-01-28 12:54:57.258959",
|
"modified": "2021-08-23 14:40:15.214350",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Customer",
|
"name": "Customer",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user