Merge branch 'develop' into develop
This commit is contained in:
commit
33c314b704
@ -3,29 +3,9 @@ from frappe import _
|
||||
|
||||
|
||||
def validate(doc, method):
|
||||
set_primary_email(doc)
|
||||
set_primary_mobile_no(doc)
|
||||
doc.set_primary_email()
|
||||
doc.set_primary("mobile_no")
|
||||
update_deals_email_mobile_no(doc)
|
||||
|
||||
|
||||
def set_primary_email(doc):
|
||||
if not doc.email_ids:
|
||||
return
|
||||
|
||||
if len(doc.email_ids) == 1:
|
||||
doc.email_ids[0].is_primary = 1
|
||||
|
||||
|
||||
def set_primary_mobile_no(doc):
|
||||
if not doc.phone_nos:
|
||||
return
|
||||
|
||||
if len(doc.phone_nos) == 1:
|
||||
doc.phone_nos[0].is_primary_mobile_no = 1
|
||||
|
||||
|
||||
def update_deals_email_mobile_no(doc):
|
||||
linked_deals = frappe.get_all(
|
||||
"CRM Contacts",
|
||||
@ -45,12 +25,7 @@ def update_deals_email_mobile_no(doc):
|
||||
def get_contact(name):
|
||||
Contact = frappe.qb.DocType("Contact")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(Contact)
|
||||
.select("*")
|
||||
.where(Contact.name == name)
|
||||
.limit(1)
|
||||
)
|
||||
query = frappe.qb.from_(Contact).select("*").where(Contact.name == name).limit(1)
|
||||
|
||||
contact = query.run(as_dict=True)
|
||||
if not len(contact):
|
||||
@ -66,6 +41,7 @@ def get_contact(name):
|
||||
)
|
||||
return contact
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_linked_deals(contact):
|
||||
"""Get linked deals for a contact"""
|
||||
@ -109,12 +85,14 @@ def create_new(contact, field, value):
|
||||
if not frappe.has_permission("Contact", "write", contact):
|
||||
frappe.throw("Not permitted", frappe.PermissionError)
|
||||
|
||||
contact = frappe.get_doc("Contact", contact)
|
||||
contact = frappe.get_cached_doc("Contact", contact)
|
||||
|
||||
if field == "email":
|
||||
contact.append("email_ids", {"email_id": value})
|
||||
email = {"email_id": value, "is_primary": 1 if len(contact.email_ids) == 0 else 0}
|
||||
contact.append("email_ids", email)
|
||||
elif field in ("mobile_no", "phone"):
|
||||
contact.append("phone_nos", {"phone": value})
|
||||
mobile_no = {"phone": value, "is_primary_mobile_no": 1 if len(contact.phone_nos) == 0 else 0}
|
||||
contact.append("phone_nos", mobile_no)
|
||||
else:
|
||||
frappe.throw("Invalid field")
|
||||
|
||||
@ -174,10 +152,10 @@ def search_emails(txt: str):
|
||||
or_filters=or_filters,
|
||||
limit_start=0,
|
||||
limit_page_length=20,
|
||||
order_by='email_id, full_name, name',
|
||||
order_by="email_id, full_name, name",
|
||||
ignore_permissions=False,
|
||||
as_list=True,
|
||||
strict=False,
|
||||
)
|
||||
|
||||
return results
|
||||
return results
|
||||
|
||||
@ -104,7 +104,8 @@ import NotificationsIcon from '@/components/Icons/NotificationsIcon.vue'
|
||||
import SidebarLink from '@/components/SidebarLink.vue'
|
||||
import { viewsStore } from '@/stores/views'
|
||||
import { unreadNotificationsCount } from '@/stores/notifications'
|
||||
import { TrialBanner, createResource } from 'frappe-ui'
|
||||
import { createResource } from 'frappe-ui'
|
||||
import { TrialBanner } from 'frappe-ui/frappe'
|
||||
import { computed, h, provide } from 'vue'
|
||||
import { mobileSidebarOpened as sidebarOpened } from '@/composables/settings'
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user