fix: review changes

This commit is contained in:
Anupam 2021-08-05 00:30:01 +05:30
parent a6ce1244a0
commit 2732490cbe
3 changed files with 54 additions and 81 deletions

View File

@ -12,7 +12,8 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
'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 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
}
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);
}
};

View File

@ -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"
},
@ -241,23 +240,6 @@
"label": "Address HTML",
"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",
@ -406,13 +388,6 @@
"label": "Designation",
"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",
@ -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",

View File

@ -21,18 +21,24 @@ class Lead(SellingController):
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 @@ class Lead(SellingController):
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 @@ class Lead(SellingController):
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 @@ class Lead(SellingController):
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})