fix: multiple CRM fixes (#29507)

* fix: multiple CRM fixes
This commit is contained in:
Anupam Kumar
2022-01-29 22:32:03 +05:30
committed by GitHub
parent cc4b4046ce
commit 925eca0e4a
14 changed files with 53 additions and 41 deletions

View File

@@ -5,7 +5,7 @@ frappe.ui.form.on('Campaign', {
refresh: function(frm) { refresh: function(frm) {
erpnext.toggle_naming_series(); erpnext.toggle_naming_series();
if (frm.doc.__islocal) { 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 { } else {
cur_frm.add_custom_button(__("View Leads"), function() { cur_frm.add_custom_button(__("View Leads"), function() {

View File

@@ -1,9 +1,10 @@
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt
# import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
class CRMSettings(Document): class CRMSettings(Document):
pass def validate(self):
frappe.db.set_default("campaign_naming_by", self.get("campaign_naming_by", ""))

View File

@@ -24,6 +24,14 @@ frappe.ui.form.on("Opportunity", {
frm.trigger('set_contact_link'); frm.trigger('set_contact_link');
} }
}, },
validate: function(frm) {
if (frm.doc.status == "Lost" && !frm.doc.lost_reasons.length) {
frm.trigger('set_as_lost_dialog');
frappe.throw(__("Lost Reasons are required in case opportunity is Lost."));
}
},
contact_date: function(frm) { contact_date: function(frm) {
if(frm.doc.contact_date < frappe.datetime.now_datetime()){ if(frm.doc.contact_date < frappe.datetime.now_datetime()){
frm.set_value("contact_date", ""); frm.set_value("contact_date", "");
@@ -82,7 +90,7 @@ frappe.ui.form.on("Opportunity", {
frm.trigger('setup_opportunity_from'); frm.trigger('setup_opportunity_from');
erpnext.toggle_naming_series(); erpnext.toggle_naming_series();
if(!doc.__islocal && doc.status!=="Lost") { if(!frm.is_new() && doc.status!=="Lost") {
if(doc.with_items){ if(doc.with_items){
frm.add_custom_button(__('Supplier Quotation'), frm.add_custom_button(__('Supplier Quotation'),
function() { function() {
@@ -187,11 +195,11 @@ frappe.ui.form.on("Opportunity", {
change_form_labels: function(frm) { change_form_labels: function(frm) {
let company_currency = erpnext.get_currency(frm.doc.company); let company_currency = erpnext.get_currency(frm.doc.company);
frm.set_currency_labels(["base_opportunity_amount", "base_total", "base_grand_total"], company_currency); frm.set_currency_labels(["base_opportunity_amount", "base_total"], company_currency);
frm.set_currency_labels(["opportunity_amount", "total", "grand_total"], frm.doc.currency); frm.set_currency_labels(["opportunity_amount", "total"], frm.doc.currency);
// toggle fields // toggle fields
frm.toggle_display(["conversion_rate", "base_opportunity_amount", "base_total", "base_grand_total"], frm.toggle_display(["conversion_rate", "base_opportunity_amount", "base_total"],
frm.doc.currency != company_currency); frm.doc.currency != company_currency);
}, },
@@ -209,20 +217,15 @@ frappe.ui.form.on("Opportunity", {
}, },
calculate_total: function(frm) { calculate_total: function(frm) {
let total = 0, base_total = 0, grand_total = 0, base_grand_total = 0; let total = 0, base_total = 0;
frm.doc.items.forEach(item => { frm.doc.items.forEach(item => {
total += item.amount; total += item.amount;
base_total += item.base_amount; base_total += item.base_amount;
}) })
base_grand_total = base_total + frm.doc.base_opportunity_amount;
grand_total = total + frm.doc.opportunity_amount;
frm.set_value({ frm.set_value({
'total': flt(total), 'total': flt(total),
'base_total': flt(base_total), 'base_total': flt(base_total)
'grand_total': flt(grand_total),
'base_grand_total': flt(base_grand_total)
}); });
} }

View File

@@ -42,10 +42,8 @@
"items", "items",
"section_break_32", "section_break_32",
"base_total", "base_total",
"base_grand_total",
"column_break_33", "column_break_33",
"total", "total",
"grand_total",
"contact_info", "contact_info",
"customer_address", "customer_address",
"address_display", "address_display",
@@ -475,21 +473,6 @@
"fieldname": "column_break_33", "fieldname": "column_break_33",
"fieldtype": "Column Break" "fieldtype": "Column Break"
}, },
{
"fieldname": "base_grand_total",
"fieldtype": "Currency",
"label": "Grand Total (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "grand_total",
"fieldtype": "Currency",
"label": "Grand Total",
"options": "currency",
"read_only": 1
},
{ {
"fieldname": "lost_detail_section", "fieldname": "lost_detail_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@@ -510,7 +493,7 @@
"icon": "fa fa-info-sign", "icon": "fa fa-info-sign",
"idx": 195, "idx": 195,
"links": [], "links": [],
"modified": "2021-10-21 12:04:30.151379", "modified": "2022-01-29 19:32:26.382896",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "CRM", "module": "CRM",
"name": "Opportunity", "name": "Opportunity",
@@ -547,6 +530,7 @@
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"states": [],
"subject_field": "title", "subject_field": "title",
"timeline_field": "party_name", "timeline_field": "party_name",
"title_field": "title", "title_field": "title",

View File

@@ -69,8 +69,6 @@ class Opportunity(TransactionBase):
self.total = flt(total) self.total = flt(total)
self.base_total = flt(base_total) self.base_total = flt(base_total)
self.grand_total = flt(self.total) + flt(self.opportunity_amount)
self.base_grand_total = flt(self.base_total) + flt(self.base_opportunity_amount)
def make_new_lead_if_required(self): def make_new_lead_if_required(self):
"""Set lead against new opportunity""" """Set lead against new opportunity"""

View File

@@ -3,6 +3,8 @@
frappe.ui.form.on('Prospect', { frappe.ui.form.on('Prospect', {
refresh (frm) { refresh (frm) {
frappe.dynamic_link = { doc: frm.doc, fieldname: "name", doctype: frm.doctype };
if (!frm.is_new() && frappe.boot.user.can_create.includes("Customer")) { if (!frm.is_new() && frappe.boot.user.can_create.includes("Customer")) {
frm.add_custom_button(__("Customer"), function() { frm.add_custom_button(__("Customer"), function() {
frappe.model.open_mapped_doc({ frappe.model.open_mapped_doc({

View File

@@ -16,7 +16,7 @@
"documentation_url": "https://docs.erpnext.com/docs/user/manual/en/CRM", "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/CRM",
"idx": 0, "idx": 0,
"is_complete": 0, "is_complete": 0,
"modified": "2020-07-08 14:05:42.644448", "modified": "2022-01-29 20:14:29.502145",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "CRM", "module": "CRM",
"name": "CRM", "name": "CRM",
@@ -33,6 +33,9 @@
}, },
{ {
"step": "Create and Send Quotation" "step": "Create and Send Quotation"
},
{
"step": "CRM Settings"
} }
], ],
"subtitle": "Lead, Opportunity, Customer, and more.", "subtitle": "Lead, Opportunity, Customer, and more.",

View File

@@ -5,7 +5,6 @@
"doctype": "Onboarding Step", "doctype": "Onboarding Step",
"idx": 0, "idx": 0,
"is_complete": 0, "is_complete": 0,
"is_mandatory": 0,
"is_single": 0, "is_single": 0,
"is_skipped": 0, "is_skipped": 0,
"modified": "2020-05-28 21:07:11.461172", "modified": "2020-05-28 21:07:11.461172",
@@ -13,6 +12,7 @@
"name": "Create and Send Quotation", "name": "Create and Send Quotation",
"owner": "Administrator", "owner": "Administrator",
"reference_document": "Quotation", "reference_document": "Quotation",
"show_form_tour": 0,
"show_full_form": 1, "show_full_form": 1,
"title": "Create and Send Quotation", "title": "Create and Send Quotation",
"validate_action": 1 "validate_action": 1

View File

@@ -5,7 +5,6 @@
"doctype": "Onboarding Step", "doctype": "Onboarding Step",
"idx": 0, "idx": 0,
"is_complete": 0, "is_complete": 0,
"is_mandatory": 0,
"is_single": 0, "is_single": 0,
"is_skipped": 0, "is_skipped": 0,
"modified": "2020-05-28 21:07:01.373403", "modified": "2020-05-28 21:07:01.373403",
@@ -13,6 +12,7 @@
"name": "Create Lead", "name": "Create Lead",
"owner": "Administrator", "owner": "Administrator",
"reference_document": "Lead", "reference_document": "Lead",
"show_form_tour": 0,
"show_full_form": 1, "show_full_form": 1,
"title": "Create Lead", "title": "Create Lead",
"validate_action": 1 "validate_action": 1

View File

@@ -5,7 +5,6 @@
"doctype": "Onboarding Step", "doctype": "Onboarding Step",
"idx": 0, "idx": 0,
"is_complete": 0, "is_complete": 0,
"is_mandatory": 0,
"is_single": 0, "is_single": 0,
"is_skipped": 0, "is_skipped": 0,
"modified": "2021-01-21 15:28:52.483839", "modified": "2021-01-21 15:28:52.483839",
@@ -13,6 +12,7 @@
"name": "Create Opportunity", "name": "Create Opportunity",
"owner": "Administrator", "owner": "Administrator",
"reference_document": "Opportunity", "reference_document": "Opportunity",
"show_form_tour": 0,
"show_full_form": 1, "show_full_form": 1,
"title": "Create Opportunity", "title": "Create Opportunity",
"validate_action": 1 "validate_action": 1

View File

@@ -0,0 +1,21 @@
{
"action": "Go to Page",
"creation": "2022-01-29 20:14:24.803844",
"description": "# CRM Settings\n\nCRM module\u2019s features are configurable as per your business needs. CRM Settings is the place where you can set your preferences for:\n- Campaign\n- Lead\n- Opportunity\n- Quotation",
"docstatus": 0,
"doctype": "Onboarding Step",
"idx": 0,
"is_complete": 0,
"is_single": 1,
"is_skipped": 0,
"modified": "2022-01-29 20:14:24.803844",
"modified_by": "Administrator",
"name": "CRM Settings",
"owner": "Administrator",
"path": "#crm-settings/CRM%20Settings",
"reference_document": "CRM Settings",
"show_form_tour": 0,
"show_full_form": 0,
"title": "CRM Settings",
"validate_action": 1
}

View File

@@ -5,13 +5,13 @@
"doctype": "Onboarding Step", "doctype": "Onboarding Step",
"idx": 0, "idx": 0,
"is_complete": 0, "is_complete": 0,
"is_mandatory": 0,
"is_single": 0, "is_single": 0,
"is_skipped": 0, "is_skipped": 0,
"modified": "2020-05-14 17:28:16.448676", "modified": "2020-05-14 17:28:16.448676",
"modified_by": "Administrator", "modified_by": "Administrator",
"name": "Introduction to CRM", "name": "Introduction to CRM",
"owner": "Administrator", "owner": "Administrator",
"show_form_tour": 0,
"show_full_form": 0, "show_full_form": 0,
"title": "Introduction to CRM", "title": "Introduction to CRM",
"validate_action": 1, "validate_action": 1,

View File

@@ -16,7 +16,7 @@ class SellingSettings(Document):
self.toggle_editable_rate_for_bundle_items() self.toggle_editable_rate_for_bundle_items()
def validate(self): def validate(self):
for key in ["cust_master_name", "campaign_naming_by", "customer_group", "territory", for key in ["cust_master_name", "customer_group", "territory",
"maintain_same_sales_rate", "editable_price_list_rate", "selling_price_list"]: "maintain_same_sales_rate", "editable_price_list_rate", "selling_price_list"]:
frappe.db.set_default(key, self.get(key, "")) frappe.db.set_default(key, self.get(key, ""))

View File

@@ -486,7 +486,7 @@ frappe.ui.form.on(cur_frm.doctype, {
"options": "Competitor Detail" "options": "Competitor Detail"
}, },
{ {
"fieldtype": "Text", "fieldtype": "Small Text",
"label": __("Detailed Reason"), "label": __("Detailed Reason"),
"fieldname": "detailed_reason" "fieldname": "detailed_reason"
}, },