fix: review changes
This commit is contained in:
parent
a6ce1244a0
commit
2732490cbe
@ -12,7 +12,8 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
|
|||||||
'Opportunity': this.make_opportunity
|
'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 () {
|
onload () {
|
||||||
@ -84,43 +85,17 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
render_basic_info_html() {
|
render_basic_info_html() {
|
||||||
let html='';
|
if (cur_frm.doc.contact_date) {
|
||||||
if (cur_frm.doc.lead_owner) {
|
let contact_date = frappe.datetime.obj_to_str(cur_frm.doc.contact_date)
|
||||||
html += `<div class="col-xs-2">
|
let diff_days = frappe.datetime.get_day_diff(contact_date, frappe.datetime.get_today());
|
||||||
<span><b> Lead Owner </b></span>
|
let color = diff_days > 0 ? "orange" : "green";
|
||||||
</div>
|
let message = diff_days > 0 ? __("Next Contact Date") : __("Last Contact Date");
|
||||||
<div class="col-xs-10">
|
let html = `<div class="col-xs-12">
|
||||||
<span> ${cur_frm.doc.lead_owner} </span>
|
<span class="indicator whitespace-nowrap ${color}"><span> ${message} : ${contact_date}</span></span>
|
||||||
</div>` ;
|
</div>` ;
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
cur_frm.dashboard.set_headline_alert(html);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extend_cscript(cur_frm.cscript, new erpnext.LeadController({ frm: cur_frm }));
|
extend_cscript(cur_frm.cscript, new erpnext.LeadController({ frm: cur_frm }));
|
||||||
|
|||||||
@ -16,37 +16,36 @@
|
|||||||
"middle_name",
|
"middle_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"lead_name",
|
"lead_name",
|
||||||
"email_id",
|
|
||||||
"mobile_no",
|
|
||||||
"phone",
|
|
||||||
"col_break123",
|
"col_break123",
|
||||||
"status",
|
"status",
|
||||||
"company_name",
|
"company_name",
|
||||||
"designation",
|
"designation",
|
||||||
"gender",
|
"gender",
|
||||||
|
"contact_details_section",
|
||||||
|
"email_id",
|
||||||
|
"mobile_no",
|
||||||
|
"whatsapp_no",
|
||||||
|
"column_break_16",
|
||||||
|
"phone",
|
||||||
|
"phone_ext",
|
||||||
"additional_information_section",
|
"additional_information_section",
|
||||||
"no_of_employees",
|
"no_of_employees",
|
||||||
"industry",
|
"industry",
|
||||||
"market_segment",
|
"market_segment",
|
||||||
"type",
|
|
||||||
"request_type",
|
|
||||||
"column_break_22",
|
"column_break_22",
|
||||||
"whatsapp_no",
|
|
||||||
"fax",
|
"fax",
|
||||||
"website",
|
"website",
|
||||||
|
"type",
|
||||||
|
"request_type",
|
||||||
"address_section",
|
"address_section",
|
||||||
"address_html",
|
"address_html",
|
||||||
"address_type",
|
|
||||||
"address_title",
|
|
||||||
"address_line1",
|
|
||||||
"address_line2",
|
|
||||||
"city",
|
"city",
|
||||||
|
"pincode",
|
||||||
"county",
|
"county",
|
||||||
"column_break2",
|
"column_break2",
|
||||||
"contact_html",
|
"contact_html",
|
||||||
"state",
|
"state",
|
||||||
"country",
|
"country",
|
||||||
"pincode",
|
|
||||||
"section_break_12",
|
"section_break_12",
|
||||||
"lead_owner",
|
"lead_owner",
|
||||||
"ends_on",
|
"ends_on",
|
||||||
@ -91,9 +90,9 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"in_global_search": 1,
|
"in_global_search": 1,
|
||||||
"label": "Full Name",
|
"label": "Full Name",
|
||||||
"mandatory_depends_on": "eval: !(doc.company_name)",
|
|
||||||
"oldfieldname": "lead_name",
|
"oldfieldname": "lead_name",
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
|
"read_only": 1,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -102,7 +101,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Organization Name",
|
"label": "Organization Name",
|
||||||
"mandatory_depends_on": "eval: !(doc.lead_name)",
|
"mandatory_depends_on": "eval: !(doc.first_name)",
|
||||||
"oldfieldname": "company_name",
|
"oldfieldname": "company_name",
|
||||||
"oldfieldtype": "Data"
|
"oldfieldtype": "Data"
|
||||||
},
|
},
|
||||||
@ -241,23 +240,6 @@
|
|||||||
"label": "Address HTML",
|
"label": "Address HTML",
|
||||||
"read_only": 1
|
"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",
|
"fieldname": "city",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
@ -406,13 +388,6 @@
|
|||||||
"label": "Designation",
|
"label": "Designation",
|
||||||
"options": "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",
|
"fieldname": "language",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -422,7 +397,8 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "first_name",
|
"fieldname": "first_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "First Name"
|
"label": "First Name",
|
||||||
|
"mandatory_depends_on": "eval: !(doc.company_name)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "middle_name",
|
"fieldname": "middle_name",
|
||||||
@ -457,7 +433,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"collapsible": 1,
|
"collapsible": 1,
|
||||||
"depends_on": "eval:!doc.__islocal",
|
"depends_on": "eval: !doc.__islocal",
|
||||||
"fieldname": "address_section",
|
"fieldname": "address_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Address"
|
"label": "Address"
|
||||||
@ -475,13 +451,27 @@
|
|||||||
"fieldname": "other_information_section",
|
"fieldname": "other_information_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Other Information"
|
"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",
|
"icon": "fa fa-user",
|
||||||
"idx": 5,
|
"idx": 5,
|
||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-07-28 00:20:37.768449",
|
"modified": "2021-08-04 00:24:57.208590",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "CRM",
|
"module": "CRM",
|
||||||
"name": "Lead",
|
"name": "Lead",
|
||||||
|
|||||||
@ -21,18 +21,24 @@ class Lead(SellingController):
|
|||||||
self.get("__onload").is_customer = customer
|
self.get("__onload").is_customer = customer
|
||||||
load_address_and_contact(self)
|
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):
|
def validate(self):
|
||||||
|
self.set_full_name()
|
||||||
self.set_lead_name()
|
self.set_lead_name()
|
||||||
self.set_title()
|
self.set_title()
|
||||||
|
self.set_status()
|
||||||
|
self.check_email_id_is_unique()
|
||||||
|
self.validate_email_id()
|
||||||
|
self.validate_contact_date()
|
||||||
self._prev = frappe._dict({
|
self._prev = frappe._dict({
|
||||||
"contact_date": frappe.db.get_value("Lead", self.name, "contact_date") if (not cint(self.is_new())) else None,
|
"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,
|
"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,
|
"contact_by": frappe.db.get_value("Lead", self.name, "contact_by") if (not cint(self.is_new())) else None,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.set_status()
|
def validate_email_id(self):
|
||||||
self.check_email_id_is_unique()
|
|
||||||
|
|
||||||
if self.email_id:
|
if self.email_id:
|
||||||
if not self.flags.ignore_email_validation:
|
if not self.flags.ignore_email_validation:
|
||||||
validate_email_address(self.email_id, throw=True)
|
validate_email_address(self.email_id, throw=True)
|
||||||
@ -46,6 +52,7 @@ class Lead(SellingController):
|
|||||||
if self.is_new() or not self.image:
|
if self.is_new() or not self.image:
|
||||||
self.image = has_gravatar(self.email_id)
|
self.image = has_gravatar(self.email_id)
|
||||||
|
|
||||||
|
def validate_contact_date(self):
|
||||||
if self.contact_date and getdate(self.contact_date) < getdate(nowdate()):
|
if self.contact_date and getdate(self.contact_date) < getdate(nowdate()):
|
||||||
frappe.throw(_("Next Contact Date cannot be in the past"))
|
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'])
|
linked_doc = frappe.get_doc(link['parenttype'], link['parent'])
|
||||||
|
|
||||||
if len(linked_doc.get('links')) == 1:
|
if len(linked_doc.get('links')) == 1:
|
||||||
linked_doc.delete()
|
linked_doc.delete(ignore_permissions=True)
|
||||||
else:
|
else:
|
||||||
to_remove = None
|
to_remove = None
|
||||||
for d in linked_doc.get('links'):
|
for d in linked_doc.get('links'):
|
||||||
@ -96,6 +103,7 @@ class Lead(SellingController):
|
|||||||
to_remove = d
|
to_remove = d
|
||||||
if to_remove:
|
if to_remove:
|
||||||
linked_doc.remove(to_remove)
|
linked_doc.remove(to_remove)
|
||||||
|
linked_doc.save(ignore_permissions=True)
|
||||||
|
|
||||||
def has_customer(self):
|
def has_customer(self):
|
||||||
return frappe.db.get_value("Customer", {"lead_name": self.name})
|
return frappe.db.get_value("Customer", {"lead_name": self.name})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user