mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 02:01:21 +00:00
* ci: add prettier to pre-commit
(cherry picked from commit 2c16036ef3)
* style: format js files
---------
Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Appointment', {
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.lead){
|
||||
frm.add_custom_button(frm.doc.lead,()=>{
|
||||
frappe.ui.form.on("Appointment", {
|
||||
refresh: function (frm) {
|
||||
if (frm.doc.lead) {
|
||||
frm.add_custom_button(frm.doc.lead, () => {
|
||||
frappe.set_route("Form", "Lead", frm.doc.lead);
|
||||
});
|
||||
}
|
||||
if(frm.doc.calendar_event){
|
||||
frm.add_custom_button(__(frm.doc.calendar_event),()=>{
|
||||
if (frm.doc.calendar_event) {
|
||||
frm.add_custom_button(__(frm.doc.calendar_event), () => {
|
||||
frappe.set_route("Form", "Event", frm.doc.calendar_event);
|
||||
});
|
||||
}
|
||||
},
|
||||
onload: function(frm){
|
||||
frm.set_query("appointment_with", function(){
|
||||
onload: function (frm) {
|
||||
frm.set_query("appointment_with", function () {
|
||||
return {
|
||||
filters : {
|
||||
"name": ["in", ["Customer", "Lead"]]
|
||||
}
|
||||
filters: {
|
||||
name: ["in", ["Customer", "Lead"]],
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
frappe.ui.form.on('Appointment Booking Settings', 'validate',check_times);
|
||||
frappe.ui.form.on("Appointment Booking Settings", "validate", check_times);
|
||||
function check_times(frm) {
|
||||
$.each(frm.doc.availability_of_slots || [], function (i, d) {
|
||||
let from_time = Date.parse('01/01/2019 ' + d.from_time);
|
||||
let to_time = Date.parse('01/01/2019 ' + d.to_time);
|
||||
let from_time = Date.parse("01/01/2019 " + d.from_time);
|
||||
let to_time = Date.parse("01/01/2019 " + d.to_time);
|
||||
if (from_time > to_time) {
|
||||
frappe.throw(__('In row {0} of Appointment Booking Slots: "To Time" must be later than "From Time".', [i + 1]));
|
||||
frappe.throw(
|
||||
__('In row {0} of Appointment Booking Slots: "To Time" must be later than "From Time".', [
|
||||
i + 1,
|
||||
])
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Campaign', {
|
||||
refresh: function(frm) {
|
||||
frappe.ui.form.on("Campaign", {
|
||||
refresh: function (frm) {
|
||||
erpnext.toggle_naming_series();
|
||||
|
||||
if (frm.is_new()) {
|
||||
frm.toggle_display("naming_series", frappe.boot.sysdefaults.campaign_naming_by=="Naming Series");
|
||||
frm.toggle_display(
|
||||
"naming_series",
|
||||
frappe.boot.sysdefaults.campaign_naming_by == "Naming Series"
|
||||
);
|
||||
} else {
|
||||
cur_frm.add_custom_button(__("View Leads"), function() {
|
||||
frappe.route_options = {"source": "Campaign", "campaign_name": frm.doc.name};
|
||||
frappe.set_route("List", "Lead");
|
||||
}, "fa fa-list", true);
|
||||
cur_frm.add_custom_button(
|
||||
__("View Leads"),
|
||||
function () {
|
||||
frappe.route_options = { source: "Campaign", campaign_name: frm.doc.name };
|
||||
frappe.set_route("List", "Lead");
|
||||
},
|
||||
"fa fa-list",
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Competitor', {
|
||||
frappe.ui.form.on("Competitor", {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
|
||||
@@ -5,12 +5,12 @@ frappe.ui.form.on("Contract", {
|
||||
contract_template: function (frm) {
|
||||
if (frm.doc.contract_template) {
|
||||
frappe.call({
|
||||
method: 'erpnext.crm.doctype.contract_template.contract_template.get_contract_template',
|
||||
method: "erpnext.crm.doctype.contract_template.contract_template.get_contract_template",
|
||||
args: {
|
||||
template_name: frm.doc.contract_template,
|
||||
doc: frm.doc
|
||||
doc: frm.doc,
|
||||
},
|
||||
callback: function(r) {
|
||||
callback: function (r) {
|
||||
if (r && r.message) {
|
||||
let contract_template = r.message.contract_template;
|
||||
frm.set_value("contract_terms", r.message.contract_terms);
|
||||
@@ -18,15 +18,15 @@ frappe.ui.form.on("Contract", {
|
||||
|
||||
if (frm.doc.requires_fulfilment) {
|
||||
// Populate the fulfilment terms table from a contract template, if any
|
||||
r.message.contract_template.fulfilment_terms.forEach(element => {
|
||||
r.message.contract_template.fulfilment_terms.forEach((element) => {
|
||||
let d = frm.add_child("fulfilment_terms");
|
||||
d.requirement = element.requirement;
|
||||
});
|
||||
frm.refresh_field("fulfilment_terms");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
frappe.listview_settings['Contract'] = {
|
||||
frappe.listview_settings["Contract"] = {
|
||||
add_fields: ["status"],
|
||||
get_indicator: function (doc) {
|
||||
if (doc.status == "Unsigned") {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Contract Fulfilment Checklist', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Contract Fulfilment Checklist", {
|
||||
refresh: function (frm) {},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Contract Template', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Contract Template", {
|
||||
refresh: function (frm) {},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('CRM Settings', {
|
||||
frappe.ui.form.on("CRM Settings", {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Email Campaign', {
|
||||
email_campaign_for: function(frm) {
|
||||
frm.set_value('recipient', '');
|
||||
}
|
||||
frappe.ui.form.on("Email Campaign", {
|
||||
email_campaign_for: function (frm) {
|
||||
frm.set_value("recipient", "");
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
frappe.listview_settings['Email Campaign'] = {
|
||||
get_indicator: function(doc) {
|
||||
frappe.listview_settings["Email Campaign"] = {
|
||||
get_indicator: function (doc) {
|
||||
var colors = {
|
||||
"Unsubscribed": "red",
|
||||
"Scheduled": "blue",
|
||||
Unsubscribed: "red",
|
||||
Scheduled: "blue",
|
||||
"In Progress": "orange",
|
||||
"Completed": "green"
|
||||
Completed: "green",
|
||||
};
|
||||
return [__(doc.status), colors[doc.status], "status,=," + doc.status];
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,41 +5,45 @@ frappe.provide("erpnext");
|
||||
cur_frm.email_field = "email_id";
|
||||
|
||||
erpnext.LeadController = class LeadController extends frappe.ui.form.Controller {
|
||||
setup () {
|
||||
setup() {
|
||||
this.frm.make_methods = {
|
||||
'Customer': this.make_customer,
|
||||
'Quotation': this.make_quotation,
|
||||
'Opportunity': this.make_opportunity
|
||||
Customer: this.make_customer,
|
||||
Quotation: this.make_quotation,
|
||||
Opportunity: this.make_opportunity,
|
||||
};
|
||||
|
||||
// For avoiding integration issues.
|
||||
this.frm.set_df_property('first_name', 'reqd', true);
|
||||
this.frm.set_df_property("first_name", "reqd", true);
|
||||
}
|
||||
|
||||
onload () {
|
||||
onload() {
|
||||
this.frm.set_query("customer", function (doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.customer_query" }
|
||||
return { query: "erpnext.controllers.queries.customer_query" };
|
||||
});
|
||||
|
||||
this.frm.set_query("lead_owner", function (doc, cdt, cdn) {
|
||||
return { query: "frappe.core.doctype.user.user.user_query" }
|
||||
return { query: "frappe.core.doctype.user.user.user_query" };
|
||||
});
|
||||
}
|
||||
|
||||
refresh () {
|
||||
refresh() {
|
||||
var me = this;
|
||||
let doc = this.frm.doc;
|
||||
erpnext.toggle_naming_series();
|
||||
|
||||
if (!this.frm.is_new() && doc.__onload && !doc.__onload.is_customer) {
|
||||
this.frm.add_custom_button(__("Customer"), this.make_customer, __("Create"));
|
||||
this.frm.add_custom_button(__("Opportunity"), function() {
|
||||
me.frm.trigger("make_opportunity");
|
||||
}, __("Create"));
|
||||
this.frm.add_custom_button(
|
||||
__("Opportunity"),
|
||||
function () {
|
||||
me.frm.trigger("make_opportunity");
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
this.frm.add_custom_button(__("Quotation"), this.make_quotation, __("Create"));
|
||||
if (!doc.__onload.linked_prospects.length) {
|
||||
this.frm.add_custom_button(__("Prospect"), this.make_prospect, __("Create"));
|
||||
this.frm.add_custom_button(__('Add to Prospect'), this.add_lead_to_prospect, __('Action'));
|
||||
this.frm.add_custom_button(__("Add to Prospect"), this.add_lead_to_prospect, __("Action"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,51 +57,55 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
|
||||
this.show_activities();
|
||||
}
|
||||
|
||||
add_lead_to_prospect () {
|
||||
add_lead_to_prospect() {
|
||||
let me = this;
|
||||
frappe.prompt([
|
||||
{
|
||||
fieldname: 'prospect',
|
||||
label: __('Prospect'),
|
||||
fieldtype: 'Link',
|
||||
options: 'Prospect',
|
||||
reqd: 1
|
||||
}
|
||||
],
|
||||
function(data) {
|
||||
frappe.call({
|
||||
method: 'erpnext.crm.doctype.lead.lead.add_lead_to_prospect',
|
||||
args: {
|
||||
'lead': me.frm.doc.name,
|
||||
'prospect': data.prospect
|
||||
frappe.prompt(
|
||||
[
|
||||
{
|
||||
fieldname: "prospect",
|
||||
label: __("Prospect"),
|
||||
fieldtype: "Link",
|
||||
options: "Prospect",
|
||||
reqd: 1,
|
||||
},
|
||||
callback: function(r) {
|
||||
if (!r.exc) {
|
||||
me.frm.reload_doc();
|
||||
}
|
||||
},
|
||||
freeze: true,
|
||||
freeze_message: __('Adding Lead to Prospect...')
|
||||
});
|
||||
}, __('Add Lead to Prospect'), __('Add'));
|
||||
],
|
||||
function (data) {
|
||||
frappe.call({
|
||||
method: "erpnext.crm.doctype.lead.lead.add_lead_to_prospect",
|
||||
args: {
|
||||
lead: me.frm.doc.name,
|
||||
prospect: data.prospect,
|
||||
},
|
||||
callback: function (r) {
|
||||
if (!r.exc) {
|
||||
me.frm.reload_doc();
|
||||
}
|
||||
},
|
||||
freeze: true,
|
||||
freeze_message: __("Adding Lead to Prospect..."),
|
||||
});
|
||||
},
|
||||
__("Add Lead to Prospect"),
|
||||
__("Add")
|
||||
);
|
||||
}
|
||||
|
||||
make_customer () {
|
||||
make_customer() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.lead.lead.make_customer",
|
||||
frm: cur_frm
|
||||
})
|
||||
frm: cur_frm,
|
||||
});
|
||||
}
|
||||
|
||||
make_quotation () {
|
||||
make_quotation() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.lead.lead.make_quotation",
|
||||
frm: cur_frm
|
||||
})
|
||||
frm: cur_frm,
|
||||
});
|
||||
}
|
||||
|
||||
make_prospect () {
|
||||
frappe.model.with_doctype("Prospect", function() {
|
||||
make_prospect() {
|
||||
frappe.model.with_doctype("Prospect", function () {
|
||||
let prospect = frappe.model.get_new_doc("Prospect");
|
||||
prospect.company_name = cur_frm.doc.company_name;
|
||||
prospect.no_of_employees = cur_frm.doc.no_of_employees;
|
||||
@@ -109,14 +117,14 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
|
||||
prospect.prospect_owner = cur_frm.doc.lead_owner;
|
||||
prospect.notes = cur_frm.doc.notes;
|
||||
|
||||
let leads_row = frappe.model.add_child(prospect, 'leads');
|
||||
let leads_row = frappe.model.add_child(prospect, "leads");
|
||||
leads_row.lead = cur_frm.doc.name;
|
||||
|
||||
frappe.set_route("Form", "Prospect", prospect.name);
|
||||
});
|
||||
}
|
||||
|
||||
company_name () {
|
||||
company_name() {
|
||||
if (!this.frm.doc.lead_name) {
|
||||
this.frm.set_value("lead_name", this.frm.doc.company_name);
|
||||
}
|
||||
@@ -145,86 +153,91 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
extend_cscript(cur_frm.cscript, new erpnext.LeadController({ frm: cur_frm }));
|
||||
|
||||
frappe.ui.form.on("Lead", {
|
||||
make_opportunity: async function(frm) {
|
||||
let existing_prospect = (await frappe.db.get_value("Prospect Lead",
|
||||
{
|
||||
"lead": frm.doc.name
|
||||
},
|
||||
"name", null, "Prospect"
|
||||
)).message.name;
|
||||
make_opportunity: async function (frm) {
|
||||
let existing_prospect = (
|
||||
await frappe.db.get_value(
|
||||
"Prospect Lead",
|
||||
{
|
||||
lead: frm.doc.name,
|
||||
},
|
||||
"name",
|
||||
null,
|
||||
"Prospect"
|
||||
)
|
||||
).message.name;
|
||||
|
||||
if (!existing_prospect) {
|
||||
var fields = [
|
||||
{
|
||||
"label": "Create Prospect",
|
||||
"fieldname": "create_prospect",
|
||||
"fieldtype": "Check",
|
||||
"default": 1
|
||||
label: "Create Prospect",
|
||||
fieldname: "create_prospect",
|
||||
fieldtype: "Check",
|
||||
default: 1,
|
||||
},
|
||||
{
|
||||
"label": "Prospect Name",
|
||||
"fieldname": "prospect_name",
|
||||
"fieldtype": "Data",
|
||||
"default": frm.doc.company_name,
|
||||
"depends_on": "create_prospect"
|
||||
}
|
||||
label: "Prospect Name",
|
||||
fieldname: "prospect_name",
|
||||
fieldtype: "Data",
|
||||
default: frm.doc.company_name,
|
||||
depends_on: "create_prospect",
|
||||
},
|
||||
];
|
||||
}
|
||||
let existing_contact = (await frappe.db.get_value("Contact",
|
||||
{
|
||||
"first_name": frm.doc.first_name || frm.doc.lead_name,
|
||||
"last_name": frm.doc.last_name
|
||||
},
|
||||
"name"
|
||||
)).message.name;
|
||||
let existing_contact = (
|
||||
await frappe.db.get_value(
|
||||
"Contact",
|
||||
{
|
||||
first_name: frm.doc.first_name || frm.doc.lead_name,
|
||||
last_name: frm.doc.last_name,
|
||||
},
|
||||
"name"
|
||||
)
|
||||
).message.name;
|
||||
|
||||
if (!existing_contact) {
|
||||
fields.push(
|
||||
{
|
||||
"label": "Create Contact",
|
||||
"fieldname": "create_contact",
|
||||
"fieldtype": "Check",
|
||||
"default": "1"
|
||||
}
|
||||
);
|
||||
fields.push({
|
||||
label: "Create Contact",
|
||||
fieldname: "create_contact",
|
||||
fieldtype: "Check",
|
||||
default: "1",
|
||||
});
|
||||
}
|
||||
|
||||
if (fields) {
|
||||
var d = new frappe.ui.Dialog({
|
||||
title: __('Create Opportunity'),
|
||||
title: __("Create Opportunity"),
|
||||
fields: fields,
|
||||
primary_action: function() {
|
||||
primary_action: function () {
|
||||
var data = d.get_values();
|
||||
frappe.call({
|
||||
method: 'create_prospect_and_contact',
|
||||
method: "create_prospect_and_contact",
|
||||
doc: frm.doc,
|
||||
args: {
|
||||
data: data,
|
||||
},
|
||||
freeze: true,
|
||||
callback: function(r) {
|
||||
callback: function (r) {
|
||||
if (!r.exc) {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
|
||||
frm: frm
|
||||
frm: frm,
|
||||
});
|
||||
}
|
||||
d.hide();
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
primary_action_label: __('Create')
|
||||
primary_action_label: __("Create"),
|
||||
});
|
||||
d.show();
|
||||
} else {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
|
||||
frm: frm
|
||||
frm: frm,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,28 +1,42 @@
|
||||
frappe.listview_settings['Lead'] = {
|
||||
onload: function(listview) {
|
||||
frappe.listview_settings["Lead"] = {
|
||||
onload: function (listview) {
|
||||
if (frappe.boot.user.can_create.includes("Prospect")) {
|
||||
listview.page.add_action_item(__("Create Prospect"), function() {
|
||||
frappe.model.with_doctype("Prospect", function() {
|
||||
listview.page.add_action_item(__("Create Prospect"), function () {
|
||||
frappe.model.with_doctype("Prospect", function () {
|
||||
let prospect = frappe.model.get_new_doc("Prospect");
|
||||
let leads = listview.get_checked_items();
|
||||
frappe.db.get_value("Lead", leads[0].name, ["company_name", "no_of_employees", "industry", "market_segment", "territory", "fax", "website", "lead_owner"], (r) => {
|
||||
prospect.company_name = r.company_name;
|
||||
prospect.no_of_employees = r.no_of_employees;
|
||||
prospect.industry = r.industry;
|
||||
prospect.market_segment = r.market_segment;
|
||||
prospect.territory = r.territory;
|
||||
prospect.fax = r.fax;
|
||||
prospect.website = r.website;
|
||||
prospect.prospect_owner = r.lead_owner;
|
||||
frappe.db.get_value(
|
||||
"Lead",
|
||||
leads[0].name,
|
||||
[
|
||||
"company_name",
|
||||
"no_of_employees",
|
||||
"industry",
|
||||
"market_segment",
|
||||
"territory",
|
||||
"fax",
|
||||
"website",
|
||||
"lead_owner",
|
||||
],
|
||||
(r) => {
|
||||
prospect.company_name = r.company_name;
|
||||
prospect.no_of_employees = r.no_of_employees;
|
||||
prospect.industry = r.industry;
|
||||
prospect.market_segment = r.market_segment;
|
||||
prospect.territory = r.territory;
|
||||
prospect.fax = r.fax;
|
||||
prospect.website = r.website;
|
||||
prospect.prospect_owner = r.lead_owner;
|
||||
|
||||
leads.forEach(function(lead) {
|
||||
let lead_prospect_row = frappe.model.add_child(prospect, 'leads');
|
||||
lead_prospect_row.lead = lead.name;
|
||||
});
|
||||
frappe.set_route("Form", "Prospect", prospect.name);
|
||||
});
|
||||
leads.forEach(function (lead) {
|
||||
let lead_prospect_row = frappe.model.add_child(prospect, "leads");
|
||||
lead_prospect_row.lead = lead.name;
|
||||
});
|
||||
frappe.set_route("Form", "Prospect", prospect.name);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Lead Source', {
|
||||
frappe.ui.form.on("Lead Source", {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Lost Reason Detail', {
|
||||
refresh: function() {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Lost Reason Detail", {
|
||||
refresh: function () {},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Market Segment', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Market Segment", {
|
||||
refresh: function (frm) {},
|
||||
});
|
||||
|
||||
@@ -4,38 +4,37 @@ frappe.provide("erpnext.crm");
|
||||
erpnext.pre_sales.set_as_lost("Opportunity");
|
||||
erpnext.sales_common.setup_selling_controller();
|
||||
|
||||
|
||||
frappe.ui.form.on("Opportunity", {
|
||||
setup: function(frm) {
|
||||
setup: function (frm) {
|
||||
frm.custom_make_buttons = {
|
||||
'Quotation': 'Quotation',
|
||||
'Supplier Quotation': 'Supplier Quotation'
|
||||
Quotation: "Quotation",
|
||||
"Supplier Quotation": "Supplier Quotation",
|
||||
};
|
||||
|
||||
frm.set_query("opportunity_from", function() {
|
||||
return{
|
||||
"filters": {
|
||||
"name": ["in", ["Customer", "Lead", "Prospect"]],
|
||||
}
|
||||
}
|
||||
frm.set_query("opportunity_from", function () {
|
||||
return {
|
||||
filters: {
|
||||
name: ["in", ["Customer", "Lead", "Prospect"]],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.email_field = "contact_email";
|
||||
},
|
||||
|
||||
validate: function(frm) {
|
||||
validate: function (frm) {
|
||||
if (frm.doc.status == "Lost" && !frm.doc.lost_reasons.length) {
|
||||
frm.trigger('set_as_lost_dialog');
|
||||
frm.trigger("set_as_lost_dialog");
|
||||
frappe.throw(__("Lost Reasons are required in case opportunity is Lost."));
|
||||
}
|
||||
},
|
||||
|
||||
onload_post_render: function(frm) {
|
||||
onload_post_render: function (frm) {
|
||||
frm.get_field("items").grid.set_multiple_add("item_code", "qty");
|
||||
},
|
||||
|
||||
party_name: function(frm) {
|
||||
frm.trigger('set_contact_link');
|
||||
party_name: function (frm) {
|
||||
frm.trigger("set_contact_link");
|
||||
|
||||
if (frm.doc.opportunity_from == "Customer") {
|
||||
erpnext.utils.get_party_details(frm);
|
||||
@@ -43,75 +42,86 @@ frappe.ui.form.on("Opportunity", {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
|
||||
source_name: frm.doc.party_name,
|
||||
frm: frm
|
||||
frm: frm,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
status:function(frm){
|
||||
if (frm.doc.status == "Lost"){
|
||||
frm.trigger('set_as_lost_dialog');
|
||||
status: function (frm) {
|
||||
if (frm.doc.status == "Lost") {
|
||||
frm.trigger("set_as_lost_dialog");
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
customer_address: function(frm, cdt, cdn) {
|
||||
erpnext.utils.get_address_display(frm, 'customer_address', 'address_display', false);
|
||||
customer_address: function (frm, cdt, cdn) {
|
||||
erpnext.utils.get_address_display(frm, "customer_address", "address_display", false);
|
||||
},
|
||||
|
||||
contact_person: erpnext.utils.get_contact_details,
|
||||
|
||||
opportunity_from: function(frm) {
|
||||
frm.trigger('setup_opportunity_from');
|
||||
opportunity_from: function (frm) {
|
||||
frm.trigger("setup_opportunity_from");
|
||||
|
||||
frm.set_value("party_name", "");
|
||||
},
|
||||
|
||||
setup_opportunity_from: function(frm) {
|
||||
frm.trigger('setup_queries');
|
||||
setup_opportunity_from: function (frm) {
|
||||
frm.trigger("setup_queries");
|
||||
frm.trigger("set_dynamic_field_label");
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
var doc = frm.doc;
|
||||
frm.trigger('setup_opportunity_from');
|
||||
frm.trigger("setup_opportunity_from");
|
||||
erpnext.toggle_naming_series();
|
||||
|
||||
if(!frm.is_new() && doc.status!=="Lost") {
|
||||
if(doc.items){
|
||||
frm.add_custom_button(__('Supplier Quotation'),
|
||||
function() {
|
||||
frm.trigger("make_supplier_quotation")
|
||||
}, __('Create'));
|
||||
if (!frm.is_new() && doc.status !== "Lost") {
|
||||
if (doc.items) {
|
||||
frm.add_custom_button(
|
||||
__("Supplier Quotation"),
|
||||
function () {
|
||||
frm.trigger("make_supplier_quotation");
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
|
||||
frm.add_custom_button(__('Request For Quotation'),
|
||||
function() {
|
||||
frm.trigger("make_request_for_quotation")
|
||||
}, __('Create'));
|
||||
frm.add_custom_button(
|
||||
__("Request For Quotation"),
|
||||
function () {
|
||||
frm.trigger("make_request_for_quotation");
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
|
||||
if (frm.doc.opportunity_from != "Customer") {
|
||||
frm.add_custom_button(__('Customer'),
|
||||
function() {
|
||||
frm.trigger("make_customer")
|
||||
}, __('Create'));
|
||||
frm.add_custom_button(
|
||||
__("Customer"),
|
||||
function () {
|
||||
frm.trigger("make_customer");
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
|
||||
frm.add_custom_button(__('Quotation'),
|
||||
function() {
|
||||
frm.trigger("create_quotation")
|
||||
}, __('Create'));
|
||||
frm.add_custom_button(
|
||||
__("Quotation"),
|
||||
function () {
|
||||
frm.trigger("create_quotation");
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
|
||||
if(!frm.doc.__islocal && frm.perm[0].write && frm.doc.docstatus==0) {
|
||||
if(frm.doc.status==="Open") {
|
||||
frm.add_custom_button(__("Close"), function() {
|
||||
if (!frm.doc.__islocal && frm.perm[0].write && frm.doc.docstatus == 0) {
|
||||
if (frm.doc.status === "Open") {
|
||||
frm.add_custom_button(__("Close"), function () {
|
||||
frm.set_value("status", "Closed");
|
||||
frm.save();
|
||||
});
|
||||
} else {
|
||||
frm.add_custom_button(__("Reopen"), function() {
|
||||
frm.set_value("lost_reasons",[])
|
||||
frm.add_custom_button(__("Reopen"), function () {
|
||||
frm.set_value("lost_reasons", []);
|
||||
frm.set_value("status", "Open");
|
||||
frm.save();
|
||||
});
|
||||
@@ -126,141 +136,149 @@ frappe.ui.form.on("Opportunity", {
|
||||
}
|
||||
|
||||
if (frm.doc.opportunity_from && frm.doc.party_name) {
|
||||
frm.trigger('set_contact_link');
|
||||
frm.trigger("set_contact_link");
|
||||
}
|
||||
},
|
||||
|
||||
set_contact_link: function(frm) {
|
||||
if(frm.doc.opportunity_from == "Customer" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'party_name', doctype: 'Customer'}
|
||||
} else if(frm.doc.opportunity_from == "Lead" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'party_name', doctype: 'Lead'}
|
||||
set_contact_link: function (frm) {
|
||||
if (frm.doc.opportunity_from == "Customer" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = { doc: frm.doc, fieldname: "party_name", doctype: "Customer" };
|
||||
} else if (frm.doc.opportunity_from == "Lead" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = { doc: frm.doc, fieldname: "party_name", doctype: "Lead" };
|
||||
} else if (frm.doc.opportunity_from == "Prospect" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'party_name', doctype: 'Prospect'}
|
||||
frappe.dynamic_link = { doc: frm.doc, fieldname: "party_name", doctype: "Prospect" };
|
||||
}
|
||||
},
|
||||
|
||||
currency: function(frm) {
|
||||
currency: function (frm) {
|
||||
let company_currency = erpnext.get_currency(frm.doc.company);
|
||||
if (company_currency != frm.doc.company) {
|
||||
frappe.call({
|
||||
method: "erpnext.setup.utils.get_exchange_rate",
|
||||
args: {
|
||||
from_currency: frm.doc.currency,
|
||||
to_currency: company_currency
|
||||
to_currency: company_currency,
|
||||
},
|
||||
callback: function(r) {
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
frm.set_value('conversion_rate', flt(r.message));
|
||||
frm.set_df_property('conversion_rate', 'description', '1 ' + frm.doc.currency
|
||||
+ ' = [?] ' + company_currency);
|
||||
frm.set_value("conversion_rate", flt(r.message));
|
||||
frm.set_df_property(
|
||||
"conversion_rate",
|
||||
"description",
|
||||
"1 " + frm.doc.currency + " = [?] " + company_currency
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
frm.set_value('conversion_rate', 1.0);
|
||||
frm.set_df_property('conversion_rate', 'hidden', 1);
|
||||
frm.set_df_property('conversion_rate', 'description', '');
|
||||
frm.set_value("conversion_rate", 1.0);
|
||||
frm.set_df_property("conversion_rate", "hidden", 1);
|
||||
frm.set_df_property("conversion_rate", "description", "");
|
||||
}
|
||||
|
||||
frm.trigger('opportunity_amount');
|
||||
frm.trigger('set_dynamic_field_label');
|
||||
frm.trigger("opportunity_amount");
|
||||
frm.trigger("set_dynamic_field_label");
|
||||
},
|
||||
|
||||
opportunity_amount: function(frm) {
|
||||
frm.set_value('base_opportunity_amount', flt(frm.doc.opportunity_amount) * flt(frm.doc.conversion_rate));
|
||||
opportunity_amount: function (frm) {
|
||||
frm.set_value(
|
||||
"base_opportunity_amount",
|
||||
flt(frm.doc.opportunity_amount) * flt(frm.doc.conversion_rate)
|
||||
);
|
||||
},
|
||||
|
||||
set_dynamic_field_label: function(frm){
|
||||
set_dynamic_field_label: function (frm) {
|
||||
if (frm.doc.opportunity_from) {
|
||||
frm.set_df_property("party_name", "label", frm.doc.opportunity_from);
|
||||
}
|
||||
frm.trigger('change_grid_labels');
|
||||
frm.trigger('change_form_labels');
|
||||
frm.trigger("change_grid_labels");
|
||||
frm.trigger("change_form_labels");
|
||||
},
|
||||
|
||||
make_supplier_quotation: function(frm) {
|
||||
make_supplier_quotation: function (frm) {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_supplier_quotation",
|
||||
frm: frm
|
||||
})
|
||||
frm: frm,
|
||||
});
|
||||
},
|
||||
|
||||
make_request_for_quotation: function(frm) {
|
||||
make_request_for_quotation: function (frm) {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_request_for_quotation",
|
||||
frm: frm
|
||||
})
|
||||
frm: frm,
|
||||
});
|
||||
},
|
||||
|
||||
change_form_labels: function(frm) {
|
||||
change_form_labels: function (frm) {
|
||||
let company_currency = erpnext.get_currency(frm.doc.company);
|
||||
frm.set_currency_labels(["base_opportunity_amount", "base_total"], company_currency);
|
||||
frm.set_currency_labels(["opportunity_amount", "total"], frm.doc.currency);
|
||||
|
||||
// toggle fields
|
||||
frm.toggle_display(["conversion_rate", "base_opportunity_amount", "base_total"],
|
||||
frm.doc.currency != company_currency);
|
||||
frm.toggle_display(
|
||||
["conversion_rate", "base_opportunity_amount", "base_total"],
|
||||
frm.doc.currency != company_currency
|
||||
);
|
||||
},
|
||||
|
||||
change_grid_labels: function(frm) {
|
||||
change_grid_labels: function (frm) {
|
||||
let company_currency = erpnext.get_currency(frm.doc.company);
|
||||
frm.set_currency_labels(["base_rate", "base_amount"], company_currency, "items");
|
||||
frm.set_currency_labels(["rate", "amount"], frm.doc.currency, "items");
|
||||
|
||||
let item_grid = frm.fields_dict.items.grid;
|
||||
$.each(["base_rate", "base_amount"], function(i, fname) {
|
||||
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
||||
$.each(["base_rate", "base_amount"], function (i, fname) {
|
||||
if (frappe.meta.get_docfield(item_grid.doctype, fname))
|
||||
item_grid.set_column_disp(fname, frm.doc.currency != company_currency);
|
||||
});
|
||||
frm.refresh_fields();
|
||||
},
|
||||
|
||||
calculate_total: function(frm) {
|
||||
let total = 0, base_total = 0;
|
||||
frm.doc.items.forEach(item => {
|
||||
calculate_total: function (frm) {
|
||||
let total = 0,
|
||||
base_total = 0;
|
||||
frm.doc.items.forEach((item) => {
|
||||
total += item.amount;
|
||||
base_total += item.base_amount;
|
||||
})
|
||||
});
|
||||
|
||||
frm.set_value({
|
||||
'total': flt(total),
|
||||
'base_total': flt(base_total)
|
||||
total: flt(total),
|
||||
base_total: flt(base_total),
|
||||
});
|
||||
},
|
||||
});
|
||||
frappe.ui.form.on("Opportunity Item", {
|
||||
calculate: function(frm, cdt, cdn) {
|
||||
calculate: function (frm, cdt, cdn) {
|
||||
let row = frappe.get_doc(cdt, cdn);
|
||||
frappe.model.set_value(cdt, cdn, "amount", flt(row.qty) * flt(row.rate));
|
||||
frappe.model.set_value(cdt, cdn, "base_rate", flt(frm.doc.conversion_rate) * flt(row.rate));
|
||||
frappe.model.set_value(cdt, cdn, "base_amount", flt(frm.doc.conversion_rate) * flt(row.amount));
|
||||
frm.trigger("calculate_total");
|
||||
},
|
||||
qty: function(frm, cdt, cdn) {
|
||||
qty: function (frm, cdt, cdn) {
|
||||
frm.trigger("calculate", cdt, cdn);
|
||||
},
|
||||
rate: function(frm, cdt, cdn) {
|
||||
rate: function (frm, cdt, cdn) {
|
||||
frm.trigger("calculate", cdt, cdn);
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
// TODO commonify this code
|
||||
erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller {
|
||||
onload() {
|
||||
|
||||
if(!this.frm.doc.status) {
|
||||
this.frm.set_value('status', 'Open');
|
||||
if (!this.frm.doc.status) {
|
||||
this.frm.set_value("status", "Open");
|
||||
}
|
||||
if(!this.frm.doc.company && frappe.defaults.get_user_default("Company")) {
|
||||
this.frm.set_value('company', frappe.defaults.get_user_default("Company"));
|
||||
if (!this.frm.doc.company && frappe.defaults.get_user_default("Company")) {
|
||||
this.frm.set_value("company", frappe.defaults.get_user_default("Company"));
|
||||
}
|
||||
if(!this.frm.doc.currency) {
|
||||
this.frm.set_value('currency', frappe.defaults.get_user_default("Currency"));
|
||||
if (!this.frm.doc.currency) {
|
||||
this.frm.set_value("currency", frappe.defaults.get_user_default("Currency"));
|
||||
}
|
||||
|
||||
this.setup_queries();
|
||||
this.frm.trigger('currency');
|
||||
this.frm.trigger("currency");
|
||||
}
|
||||
|
||||
refresh() {
|
||||
@@ -271,28 +289,27 @@ erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller {
|
||||
setup_queries() {
|
||||
var me = this;
|
||||
|
||||
me.frm.set_query('customer_address', erpnext.queries.address_query);
|
||||
me.frm.set_query("customer_address", erpnext.queries.address_query);
|
||||
|
||||
this.frm.set_query("item_code", "items", function() {
|
||||
this.frm.set_query("item_code", "items", function () {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: {'is_sales_item': 1}
|
||||
filters: { is_sales_item: 1 },
|
||||
};
|
||||
});
|
||||
|
||||
me.frm.set_query('contact_person', erpnext.queries['contact_query'])
|
||||
me.frm.set_query("contact_person", erpnext.queries["contact_query"]);
|
||||
|
||||
if (me.frm.doc.opportunity_from == "Lead") {
|
||||
me.frm.set_query('party_name', erpnext.queries['lead']);
|
||||
}
|
||||
else if (me.frm.doc.opportunity_from == "Customer") {
|
||||
me.frm.set_query('party_name', erpnext.queries['customer']);
|
||||
me.frm.set_query("party_name", erpnext.queries["lead"]);
|
||||
} else if (me.frm.doc.opportunity_from == "Customer") {
|
||||
me.frm.set_query("party_name", erpnext.queries["customer"]);
|
||||
} else if (me.frm.doc.opportunity_from == "Prospect") {
|
||||
me.frm.set_query('party_name', function() {
|
||||
me.frm.set_query("party_name", function () {
|
||||
return {
|
||||
filters: {
|
||||
"company": me.frm.doc.company
|
||||
}
|
||||
company: me.frm.doc.company,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -301,15 +318,15 @@ erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller {
|
||||
create_quotation() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation",
|
||||
frm: cur_frm
|
||||
})
|
||||
frm: cur_frm,
|
||||
});
|
||||
}
|
||||
|
||||
make_customer() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_customer",
|
||||
frm: cur_frm
|
||||
})
|
||||
frm: cur_frm,
|
||||
});
|
||||
}
|
||||
|
||||
show_notes() {
|
||||
@@ -331,22 +348,22 @@ erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller {
|
||||
}
|
||||
};
|
||||
|
||||
extend_cscript(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm}));
|
||||
extend_cscript(cur_frm.cscript, new erpnext.crm.Opportunity({ frm: cur_frm }));
|
||||
|
||||
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.item_code = function (doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.item_code) {
|
||||
return frappe.call({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.get_item_details",
|
||||
args: {"item_code":d.item_code},
|
||||
callback: function(r, rt) {
|
||||
if(r.message) {
|
||||
$.each(r.message, function(k, v) {
|
||||
args: { item_code: d.item_code },
|
||||
callback: function (r, rt) {
|
||||
if (r.message) {
|
||||
$.each(r.message, function (k, v) {
|
||||
frappe.model.set_value(cdt, cdn, k, v);
|
||||
});
|
||||
refresh_field('image_view', d.name, 'items');
|
||||
refresh_field("image_view", d.name, "items");
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
frappe.listview_settings['Opportunity'] = {
|
||||
frappe.listview_settings["Opportunity"] = {
|
||||
add_fields: ["customer_name", "opportunity_type", "opportunity_from", "status"],
|
||||
get_indicator: function(doc) {
|
||||
get_indicator: function (doc) {
|
||||
var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status];
|
||||
if(doc.status=="Quotation") {
|
||||
if (doc.status == "Quotation") {
|
||||
indicator[1] = "green";
|
||||
}
|
||||
return indicator;
|
||||
},
|
||||
onload: function(listview) {
|
||||
onload: function (listview) {
|
||||
var method = "erpnext.crm.doctype.opportunity.opportunity.set_multiple_status";
|
||||
|
||||
listview.page.add_menu_item(__("Set as Open"), function() {
|
||||
listview.call_for_selected_items(method, {"status": "Open"});
|
||||
listview.page.add_menu_item(__("Set as Open"), function () {
|
||||
listview.call_for_selected_items(method, { status: "Open" });
|
||||
});
|
||||
|
||||
listview.page.add_menu_item(__("Set as Closed"), function() {
|
||||
listview.call_for_selected_items(method, {"status": "Closed"});
|
||||
listview.page.add_menu_item(__("Set as Closed"), function () {
|
||||
listview.call_for_selected_items(method, { status: "Closed" });
|
||||
});
|
||||
|
||||
if(listview.page.fields_dict.opportunity_from) {
|
||||
listview.page.fields_dict.opportunity_from.get_query = function() {
|
||||
if (listview.page.fields_dict.opportunity_from) {
|
||||
listview.page.fields_dict.opportunity_from.get_query = function () {
|
||||
return {
|
||||
"filters": {
|
||||
"name": ["in", ["Customer", "Lead"]],
|
||||
}
|
||||
filters: {
|
||||
name: ["in", ["Customer", "Lead"]],
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Opportunity Lost Reason', {
|
||||
refresh: function() {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Opportunity Lost Reason", {
|
||||
refresh: function () {},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Opportunity Type', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Opportunity Type", {
|
||||
refresh: function (frm) {},
|
||||
});
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Prospect', {
|
||||
refresh (frm) {
|
||||
frappe.ui.form.on("Prospect", {
|
||||
refresh(frm) {
|
||||
if (!frm.is_new() && frappe.boot.user.can_create.includes("Customer")) {
|
||||
frm.add_custom_button(__("Customer"), function() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.prospect.prospect.make_customer",
|
||||
frm: frm
|
||||
});
|
||||
}, __("Create"));
|
||||
frm.add_custom_button(
|
||||
__("Customer"),
|
||||
function () {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.prospect.prospect.make_customer",
|
||||
frm: frm,
|
||||
});
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
if (!frm.is_new() && frappe.boot.user.can_create.includes("Opportunity")) {
|
||||
frm.add_custom_button(__("Opportunity"), function() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.prospect.prospect.make_opportunity",
|
||||
frm: frm
|
||||
});
|
||||
}, __("Create"));
|
||||
frm.add_custom_button(
|
||||
__("Opportunity"),
|
||||
function () {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.prospect.prospect.make_opportunity",
|
||||
frm: frm,
|
||||
});
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
|
||||
if (!frm.is_new()) {
|
||||
@@ -29,7 +37,7 @@ frappe.ui.form.on('Prospect', {
|
||||
frm.trigger("show_activities");
|
||||
},
|
||||
|
||||
show_notes (frm) {
|
||||
show_notes(frm) {
|
||||
const crm_notes = new erpnext.utils.CRMNotes({
|
||||
frm: frm,
|
||||
notes_wrapper: $(frm.fields_dict.notes_html.wrapper),
|
||||
@@ -37,7 +45,7 @@ frappe.ui.form.on('Prospect', {
|
||||
crm_notes.refresh();
|
||||
},
|
||||
|
||||
show_activities (frm) {
|
||||
show_activities(frm) {
|
||||
const crm_activities = new erpnext.utils.CRMActivities({
|
||||
frm: frm,
|
||||
open_activities_wrapper: $(frm.fields_dict.open_activities_html.wrapper),
|
||||
@@ -45,6 +53,5 @@ frappe.ui.form.on('Prospect', {
|
||||
form_wrapper: $(frm.wrapper),
|
||||
});
|
||||
crm_activities.refresh();
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Sales Stage', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Sales Stage", {
|
||||
refresh: function (frm) {},
|
||||
});
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
frappe.query_reports["Campaign Efficiency"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
"fieldname": "from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
||||
},
|
||||
{
|
||||
"fieldname": "to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
||||
}
|
||||
]
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,43 +1,44 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["First Response Time for Opportunity"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
"fieldname": "from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.add_days(frappe.datetime.nowdate(), -30)
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.add_days(frappe.datetime.nowdate(), -30),
|
||||
},
|
||||
{
|
||||
"fieldname": "to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.nowdate()
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.nowdate(),
|
||||
},
|
||||
],
|
||||
get_chart_data: function (_columns, result) {
|
||||
return {
|
||||
data: {
|
||||
labels: result.map(d => d.creation_date),
|
||||
datasets: [{
|
||||
name: "First Response Time",
|
||||
values: result.map(d => d.first_response_time)
|
||||
}]
|
||||
labels: result.map((d) => d.creation_date),
|
||||
datasets: [
|
||||
{
|
||||
name: "First Response Time",
|
||||
values: result.map((d) => d.first_response_time),
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "line",
|
||||
tooltipOptions: {
|
||||
formatTooltipY: d => {
|
||||
formatTooltipY: (d) => {
|
||||
let duration_options = {
|
||||
hide_days: 0,
|
||||
hide_seconds: 0
|
||||
hide_seconds: 0,
|
||||
};
|
||||
return frappe.utils.get_formatted_duration(d, duration_options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Lead Conversion Time"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
'reqd': 1,
|
||||
"default": frappe.datetime.add_days(frappe.datetime.nowdate(), -30)
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.add_days(frappe.datetime.nowdate(), -30),
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
'reqd': 1,
|
||||
"default":frappe.datetime.nowdate()
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.nowdate(),
|
||||
},
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,52 +1,51 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Lead Details"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": __("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": frappe.defaults.get_user_default("Company"),
|
||||
"reqd": 1
|
||||
fieldname: "company",
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
default: frappe.defaults.get_user_default("Company"),
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -12),
|
||||
"reqd": 1
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -12),
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.get_today(),
|
||||
"reqd": 1
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.get_today(),
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
"fieldname":"status",
|
||||
"label": __("Status"),
|
||||
"fieldtype": "Select",
|
||||
fieldname: "status",
|
||||
label: __("Status"),
|
||||
fieldtype: "Select",
|
||||
options: [
|
||||
{ "value": "Lead", "label": __("Lead") },
|
||||
{ "value": "Open", "label": __("Open") },
|
||||
{ "value": "Replied", "label": __("Replied") },
|
||||
{ "value": "Opportunity", "label": __("Opportunity") },
|
||||
{ "value": "Quotation", "label": __("Quotation") },
|
||||
{ "value": "Lost Quotation", "label": __("Lost Quotation") },
|
||||
{ "value": "Interested", "label": __("Interested") },
|
||||
{ "value": "Converted", "label": __("Converted") },
|
||||
{ "value": "Do Not Contact", "label": __("Do Not Contact") },
|
||||
{ value: "Lead", label: __("Lead") },
|
||||
{ value: "Open", label: __("Open") },
|
||||
{ value: "Replied", label: __("Replied") },
|
||||
{ value: "Opportunity", label: __("Opportunity") },
|
||||
{ value: "Quotation", label: __("Quotation") },
|
||||
{ value: "Lost Quotation", label: __("Lost Quotation") },
|
||||
{ value: "Interested", label: __("Interested") },
|
||||
{ value: "Converted", label: __("Converted") },
|
||||
{ value: "Do Not Contact", label: __("Do Not Contact") },
|
||||
],
|
||||
},
|
||||
{
|
||||
"fieldname":"territory",
|
||||
"label": __("Territory"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Territory",
|
||||
}
|
||||
]
|
||||
fieldname: "territory",
|
||||
label: __("Territory"),
|
||||
fieldtype: "Link",
|
||||
options: "Territory",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
frappe.query_reports["Lead Owner Efficiency"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname": "from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
||||
},
|
||||
{
|
||||
"fieldname": "to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
||||
}
|
||||
]};
|
||||
frappe.query_reports["Lead Owner Efficiency"] = {
|
||||
filters: [
|
||||
{
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
||||
},
|
||||
{
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,61 +1,60 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Lost Opportunity"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": __("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": frappe.defaults.get_user_default("Company"),
|
||||
"reqd": 1
|
||||
fieldname: "company",
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
default: frappe.defaults.get_user_default("Company"),
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -12),
|
||||
"reqd": 1
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -12),
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.get_today(),
|
||||
"reqd": 1
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.get_today(),
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
"fieldname":"lost_reason",
|
||||
"label": __("Lost Reason"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Opportunity Lost Reason"
|
||||
fieldname: "lost_reason",
|
||||
label: __("Lost Reason"),
|
||||
fieldtype: "Link",
|
||||
options: "Opportunity Lost Reason",
|
||||
},
|
||||
{
|
||||
"fieldname":"territory",
|
||||
"label": __("Territory"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Territory"
|
||||
fieldname: "territory",
|
||||
label: __("Territory"),
|
||||
fieldtype: "Link",
|
||||
options: "Territory",
|
||||
},
|
||||
{
|
||||
"fieldname":"opportunity_from",
|
||||
"label": __("Opportunity From"),
|
||||
"fieldtype": "Link",
|
||||
"options": "DocType",
|
||||
"get_query": function() {
|
||||
fieldname: "opportunity_from",
|
||||
label: __("Opportunity From"),
|
||||
fieldtype: "Link",
|
||||
options: "DocType",
|
||||
get_query: function () {
|
||||
return {
|
||||
"filters": {
|
||||
"name": ["in", ["Customer", "Lead"]],
|
||||
}
|
||||
}
|
||||
}
|
||||
filters: {
|
||||
name: ["in", ["Customer", "Lead"]],
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname":"party_name",
|
||||
"label": __("Party"),
|
||||
"fieldtype": "Dynamic Link",
|
||||
"options": "opportunity_from"
|
||||
fieldname: "party_name",
|
||||
label: __("Party"),
|
||||
fieldtype: "Dynamic Link",
|
||||
options: "opportunity_from",
|
||||
},
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Opportunity Summary by Sales Stage"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
fieldname: "based_on",
|
||||
label: __("Based On"),
|
||||
fieldtype: "Select",
|
||||
options: "Opportunity Owner\nSource\nOpportunity Type",
|
||||
default: "Opportunity Owner"
|
||||
default: "Opportunity Owner",
|
||||
},
|
||||
{
|
||||
fieldname: "data_based_on",
|
||||
label: __("Data Based On"),
|
||||
fieldtype: "Select",
|
||||
options: "Number\nAmount",
|
||||
default: "Number"
|
||||
default: "Number",
|
||||
},
|
||||
{
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
|
||||
},
|
||||
{
|
||||
fieldname: "to_date",
|
||||
@@ -33,14 +31,14 @@ frappe.query_reports["Opportunity Summary by Sales Stage"] = {
|
||||
fieldname: "status",
|
||||
label: __("Status"),
|
||||
fieldtype: "MultiSelectList",
|
||||
get_data: function() {
|
||||
get_data: function () {
|
||||
return [
|
||||
{value: "Open", description: "Status"},
|
||||
{value: "Converted", description: "Status"},
|
||||
{value: "Quotation", description: "Status"},
|
||||
{value: "Replied", description: "Status"}
|
||||
]
|
||||
}
|
||||
{ value: "Open", description: "Status" },
|
||||
{ value: "Converted", description: "Status" },
|
||||
{ value: "Quotation", description: "Status" },
|
||||
{ value: "Replied", description: "Status" },
|
||||
];
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldname: "opportunity_source",
|
||||
@@ -59,7 +57,7 @@ frappe.query_reports["Opportunity Summary by Sales Stage"] = {
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
default: frappe.defaults.get_user_default("Company")
|
||||
}
|
||||
]
|
||||
default: frappe.defaults.get_user_default("Company"),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.query_reports["Prospects Engaged But Not Converted"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
"fieldname": "lead",
|
||||
"label": __("Lead"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Lead"
|
||||
fieldname: "lead",
|
||||
label: __("Lead"),
|
||||
fieldtype: "Link",
|
||||
options: "Lead",
|
||||
},
|
||||
{
|
||||
"fieldname": "no_of_interaction",
|
||||
"label": __("Number of Interaction"),
|
||||
"fieldtype": "Int",
|
||||
"default": 1
|
||||
fieldname: "no_of_interaction",
|
||||
label: __("Number of Interaction"),
|
||||
fieldtype: "Int",
|
||||
default: 1,
|
||||
},
|
||||
{
|
||||
"fieldname": "lead_age",
|
||||
"label": __("Minimum Lead Age (Days)"),
|
||||
"fieldtype": "Int",
|
||||
"default": 60
|
||||
fieldname: "lead_age",
|
||||
label: __("Minimum Lead Age (Days)"),
|
||||
fieldtype: "Int",
|
||||
default: 60,
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,70 +1,69 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Sales Pipeline Analytics"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
fieldname: "pipeline_by",
|
||||
label: __("Pipeline By"),
|
||||
fieldtype: "Select",
|
||||
options: "Owner\nSales Stage",
|
||||
default: "Owner"
|
||||
default: "Owner",
|
||||
},
|
||||
{
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date"
|
||||
fieldtype: "Date",
|
||||
},
|
||||
{
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date"
|
||||
fieldtype: "Date",
|
||||
},
|
||||
{
|
||||
fieldname: "range",
|
||||
label: __("Range"),
|
||||
fieldtype: "Select",
|
||||
options: "Monthly\nQuarterly",
|
||||
default: "Monthly"
|
||||
default: "Monthly",
|
||||
},
|
||||
{
|
||||
fieldname: "assigned_to",
|
||||
label: __("Assigned To"),
|
||||
fieldtype: "Link",
|
||||
options: "User"
|
||||
options: "User",
|
||||
},
|
||||
{
|
||||
fieldname: "status",
|
||||
label: __("Status"),
|
||||
fieldtype: "Select",
|
||||
options: "Open\nQuotation\nConverted\nReplied"
|
||||
options: "Open\nQuotation\nConverted\nReplied",
|
||||
},
|
||||
{
|
||||
fieldname: "based_on",
|
||||
label: __("Based On"),
|
||||
fieldtype: "Select",
|
||||
options: "Number\nAmount",
|
||||
default: "Number"
|
||||
default: "Number",
|
||||
},
|
||||
{
|
||||
fieldname: "company",
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
default: frappe.defaults.get_user_default("Company")
|
||||
default: frappe.defaults.get_user_default("Company"),
|
||||
},
|
||||
{
|
||||
fieldname: "opportunity_source",
|
||||
label: __("Opportunity Source"),
|
||||
fieldtype: "Link",
|
||||
options: "Lead Source"
|
||||
options: "Lead Source",
|
||||
},
|
||||
{
|
||||
fieldname: "opportunity_type",
|
||||
label: __("Opportunity Type"),
|
||||
fieldtype: "Link",
|
||||
options: "Opportunity Type"
|
||||
options: "Opportunity Type",
|
||||
},
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user