Merge pull request #688 from frappe/develop
chore: Merge develop to main
This commit is contained in:
commit
238276070c
@ -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
|
||||
|
||||
@ -350,7 +350,9 @@ function getGroupedByRows(listRows, groupByField, columns) {
|
||||
if (!option) {
|
||||
filteredRows = listRows.filter((row) => !row[groupByField.fieldname])
|
||||
} else {
|
||||
filteredRows = listRows.filter((row) => row[groupByField.fieldname] == option)
|
||||
filteredRows = listRows.filter(
|
||||
(row) => row[groupByField.fieldname] == option,
|
||||
)
|
||||
}
|
||||
|
||||
let groupDetail = {
|
||||
@ -382,14 +384,18 @@ function getKanbanRows(data, columns) {
|
||||
}
|
||||
|
||||
function parseRows(rows, columns = []) {
|
||||
let view_type = deals.value.data.view_type
|
||||
let key = view_type === 'kanban' ? 'fieldname' : 'key'
|
||||
let type = view_type === 'kanban' ? 'fieldtype' : 'type'
|
||||
|
||||
return rows.map((deal) => {
|
||||
let _rows = {}
|
||||
deals.value.data.rows.forEach((row) => {
|
||||
_rows[row] = deal[row]
|
||||
|
||||
let fieldType = columns?.find(
|
||||
(col) => (col.key || col.value) == row,
|
||||
)?.type
|
||||
let fieldType = columns?.find((col) => (col[key] || col.value) == row)?.[
|
||||
type
|
||||
]
|
||||
|
||||
if (
|
||||
fieldType &&
|
||||
|
||||
@ -370,7 +370,9 @@ function getGroupedByRows(listRows, groupByField, columns) {
|
||||
if (!option) {
|
||||
filteredRows = listRows.filter((row) => !row[groupByField.fieldname])
|
||||
} else {
|
||||
filteredRows = listRows.filter((row) => row[groupByField.fieldname] == option)
|
||||
filteredRows = listRows.filter(
|
||||
(row) => row[groupByField.fieldname] == option,
|
||||
)
|
||||
}
|
||||
|
||||
let groupDetail = {
|
||||
@ -402,14 +404,18 @@ function getKanbanRows(data, columns) {
|
||||
}
|
||||
|
||||
function parseRows(rows, columns = []) {
|
||||
let view_type = leads.value.data.view_type
|
||||
let key = view_type === 'kanban' ? 'fieldname' : 'key'
|
||||
let type = view_type === 'kanban' ? 'fieldtype' : 'type'
|
||||
|
||||
return rows.map((lead) => {
|
||||
let _rows = {}
|
||||
leads.value?.data.rows.forEach((row) => {
|
||||
_rows[row] = lead[row]
|
||||
|
||||
let fieldType = columns?.find(
|
||||
(col) => (col.key || col.value) == row,
|
||||
)?.type
|
||||
let fieldType = columns?.find((col) => (col[key] || col.value) == row)?.[
|
||||
type
|
||||
]
|
||||
|
||||
if (
|
||||
fieldType &&
|
||||
|
||||
@ -257,14 +257,18 @@ function getKanbanRows(data, columns) {
|
||||
}
|
||||
|
||||
function parseRows(rows, columns = []) {
|
||||
let view_type = tasks.value.data.view_type
|
||||
let key = view_type === 'kanban' ? 'fieldname' : 'key'
|
||||
let type = view_type === 'kanban' ? 'fieldtype' : 'type'
|
||||
|
||||
return rows.map((task) => {
|
||||
let _rows = {}
|
||||
tasks.value?.data.rows.forEach((row) => {
|
||||
_rows[row] = task[row]
|
||||
|
||||
let fieldType = columns?.find(
|
||||
(col) => (col.key || col.value) == row,
|
||||
)?.type
|
||||
let fieldType = columns?.find((col) => (col[key] || col.value) == row)?.[
|
||||
type
|
||||
]
|
||||
|
||||
if (
|
||||
fieldType &&
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user