fix: review changes
diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js
index ad24a6e..10e3f7d 100644
--- a/erpnext/crm/doctype/lead/lead.js
+++ b/erpnext/crm/doctype/lead/lead.js
@@ -12,7 +12,8 @@
'Opportunity': this.make_opportunity
};
- this.frm.toggle_reqd("lead_name", !this.frm.doc.organization_lead);
+ // For avoiding integration issues.
+ this.frm.set_df_property('first_name', 'reqd', true);
}
onload () {
@@ -84,42 +85,16 @@
}
render_basic_info_html() {
- let html='';
- if (cur_frm.doc.lead_owner) {
- html += `<div class="col-xs-2">
- <span><b> Lead Owner </b></span>
- </div>
- <div class="col-xs-10">
- <span> ${cur_frm.doc.lead_owner} </span>
- </div>` ;
+ if (cur_frm.doc.contact_date) {
+ let contact_date = frappe.datetime.obj_to_str(cur_frm.doc.contact_date)
+ let diff_days = frappe.datetime.get_day_diff(contact_date, frappe.datetime.get_today());
+ let color = diff_days > 0 ? "orange" : "green";
+ let message = diff_days > 0 ? __("Next Contact Date") : __("Last Contact Date");
+ let html = `<div class="col-xs-12">
+ <span class="indicator whitespace-nowrap ${color}"><span> ${message} : ${contact_date}</span></span>
+ </div>` ;
+ cur_frm.dashboard.set_headline_alert(html);
}
-
- if (cur_frm.doc.email_id) {
- html += `<div class="col-xs-2">
- <span><b> Email </b></span>
- </div>
- <div class="col-xs-10">
- <span> ${cur_frm.doc.email_id} </span>
- </div>` ;
- }
-
- if (cur_frm.doc.mobile_no) {
- html += `<div class="col-xs-2">
- <span><b> Mobile </b></span>
- </div>
- <div class="col-xs-10">
- <span> ${cur_frm.doc.mobile_no} </span>
- </div>` ;
- }
-
- html += `<div class="col-xs-2">
- <span><b> Status </b></span>
- </div>
- <div class="col-xs-10">
- <span> ${cur_frm.doc.status} </span>
- </div>` ;
- html = `<div class="row">${html}</div>`;
- cur_frm.dashboard.set_headline_alert(html);
}
};
diff --git a/erpnext/crm/doctype/lead/lead.json b/erpnext/crm/doctype/lead/lead.json
index f9a500f..542977e 100644
--- a/erpnext/crm/doctype/lead/lead.json
+++ b/erpnext/crm/doctype/lead/lead.json
@@ -16,37 +16,36 @@
"middle_name",
"last_name",
"lead_name",
- "email_id",
- "mobile_no",
- "phone",
"col_break123",
"status",
"company_name",
"designation",
"gender",
+ "contact_details_section",
+ "email_id",
+ "mobile_no",
+ "whatsapp_no",
+ "column_break_16",
+ "phone",
+ "phone_ext",
"additional_information_section",
"no_of_employees",
"industry",
"market_segment",
- "type",
- "request_type",
"column_break_22",
- "whatsapp_no",
"fax",
"website",
+ "type",
+ "request_type",
"address_section",
"address_html",
- "address_type",
- "address_title",
- "address_line1",
- "address_line2",
"city",
+ "pincode",
"county",
"column_break2",
"contact_html",
"state",
"country",
- "pincode",
"section_break_12",
"lead_owner",
"ends_on",
@@ -91,9 +90,9 @@
"fieldtype": "Data",
"in_global_search": 1,
"label": "Full Name",
- "mandatory_depends_on": "eval: !(doc.company_name)",
"oldfieldname": "lead_name",
"oldfieldtype": "Data",
+ "read_only": 1,
"search_index": 1
},
{
@@ -102,7 +101,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Organization Name",
- "mandatory_depends_on": "eval: !(doc.lead_name)",
+ "mandatory_depends_on": "eval: !(doc.first_name)",
"oldfieldname": "company_name",
"oldfieldtype": "Data"
},
@@ -242,23 +241,6 @@
"read_only": 1
},
{
- "description": "Home, Work, etc.",
- "fieldname": "address_title",
- "fieldtype": "Data",
- "label": "Address Title"
- },
- {
- "fieldname": "address_line1",
- "fieldtype": "Data",
- "label": "Address Line 1",
- "mandatory_depends_on": "eval: doc.address_title && doc.address_type"
- },
- {
- "fieldname": "address_line2",
- "fieldtype": "Data",
- "label": "Address Line 2"
- },
- {
"fieldname": "city",
"fieldtype": "Data",
"label": "City/Town",
@@ -407,13 +389,6 @@
"options": "Designation"
},
{
- "default": "Billing",
- "fieldname": "address_type",
- "fieldtype": "Select",
- "label": "Address Type",
- "options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nCurrent\nPermanent\nOther"
- },
- {
"fieldname": "language",
"fieldtype": "Link",
"label": "Print Language",
@@ -422,7 +397,8 @@
{
"fieldname": "first_name",
"fieldtype": "Data",
- "label": "First Name"
+ "label": "First Name",
+ "mandatory_depends_on": "eval: !(doc.company_name)"
},
{
"fieldname": "middle_name",
@@ -457,7 +433,7 @@
},
{
"collapsible": 1,
- "depends_on": "eval:!doc.__islocal",
+ "depends_on": "eval: !doc.__islocal",
"fieldname": "address_section",
"fieldtype": "Section Break",
"label": "Address"
@@ -475,13 +451,27 @@
"fieldname": "other_information_section",
"fieldtype": "Section Break",
"label": "Other Information"
+ },
+ {
+ "fieldname": "contact_details_section",
+ "fieldtype": "Section Break",
+ "label": "Contact Details"
+ },
+ {
+ "fieldname": "column_break_16",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "phone_ext",
+ "fieldtype": "Data",
+ "label": "Phone Ext."
}
],
"icon": "fa fa-user",
"idx": 5,
"image_field": "image",
"links": [],
- "modified": "2021-07-28 00:20:37.768449",
+ "modified": "2021-08-04 00:24:57.208590",
"modified_by": "Administrator",
"module": "CRM",
"name": "Lead",
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index f09a814..33fda89 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -21,18 +21,24 @@
self.get("__onload").is_customer = customer
load_address_and_contact(self)
+ def set_full_name(self):
+ self.lead_name = " ".join(filter(None, [self.first_name, self.middle_name, self.last_name]))
+
def validate(self):
+ self.set_full_name()
self.set_lead_name()
self.set_title()
+ self.set_status()
+ self.check_email_id_is_unique()
+ self.validate_email_id()
+ self.validate_contact_date()
self._prev = frappe._dict({
"contact_date": frappe.db.get_value("Lead", self.name, "contact_date") if (not cint(self.is_new())) else None,
"ends_on": frappe.db.get_value("Lead", self.name, "ends_on") if (not cint(self.is_new())) else None,
"contact_by": frappe.db.get_value("Lead", self.name, "contact_by") if (not cint(self.is_new())) else None,
})
-
- self.set_status()
- self.check_email_id_is_unique()
-
+
+ def validate_email_id(self):
if self.email_id:
if not self.flags.ignore_email_validation:
validate_email_address(self.email_id, throw=True)
@@ -46,6 +52,7 @@
if self.is_new() or not self.image:
self.image = has_gravatar(self.email_id)
+ def validate_contact_date(self):
if self.contact_date and getdate(self.contact_date) < getdate(nowdate()):
frappe.throw(_("Next Contact Date cannot be in the past"))
@@ -88,7 +95,7 @@
linked_doc = frappe.get_doc(link['parenttype'], link['parent'])
if len(linked_doc.get('links')) == 1:
- linked_doc.delete()
+ linked_doc.delete(ignore_permissions=True)
else:
to_remove = None
for d in linked_doc.get('links'):
@@ -96,6 +103,7 @@
to_remove = d
if to_remove:
linked_doc.remove(to_remove)
+ linked_doc.save(ignore_permissions=True)
def has_customer(self):
return frappe.db.get_value("Customer", {"lead_name": self.name})