fix: Get user_id of employee instead of name
- Remove caching from lead
This commit is contained in:
parent
2295921821
commit
82cfccab2f
@ -46,9 +46,10 @@ def get_employee_email(number):
|
||||
|
||||
employees = frappe.get_all('Employee', or_filters={
|
||||
'phone': ['like', '%{}'.format(number)],
|
||||
}, limit=1)
|
||||
'user_id': ['!=', '']
|
||||
}, fields=['user_id'], limit=1)
|
||||
|
||||
employee = employees[0].name if employees else None
|
||||
employee = employees[0].user_id if employees else None
|
||||
frappe.cache().hset('employee_with_number', number, employee)
|
||||
|
||||
return employee
|
@ -23,13 +23,6 @@ class Lead(SellingController):
|
||||
self.get("__onload").is_customer = customer
|
||||
load_address_and_contact(self)
|
||||
|
||||
def on_update(self):
|
||||
doc = self.get_doc_before_save()
|
||||
for field in ['mobile_no', 'phone']:
|
||||
old_number = doc.get(field)
|
||||
if old_number and old_number != self.get(field):
|
||||
frappe.cache().hdel('lead_with_number', old_number)
|
||||
|
||||
def validate(self):
|
||||
self.set_lead_name()
|
||||
self._prev = frappe._dict({
|
||||
@ -241,15 +234,11 @@ def make_lead_from_communication(communication, ignore_communication_links=False
|
||||
def get_lead_with_phone_number(number):
|
||||
if not number: return
|
||||
|
||||
lead = frappe.cache().hget('lead_with_number', number)
|
||||
if lead: return lead
|
||||
|
||||
leads = frappe.get_all('Lead', or_filters={
|
||||
'phone': ['like', '%{}'.format(number)],
|
||||
'mobile_no': ['like', '%{}'.format(number)]
|
||||
}, limit=1)
|
||||
|
||||
lead = leads[0].name if leads else None
|
||||
frappe.cache().hset('lead_with_number', number, lead)
|
||||
|
||||
return lead
|
Loading…
Reference in New Issue
Block a user