Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Merge develop to main #543

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 37 additions & 34 deletions crm/api/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ def sort_options(doctype: str):
{
"label": _(field.label),
"value": field.fieldname,
"fieldname": field.fieldname,
}
for field in fields
if field.label and field.fieldname
]

standard_fields = [
{"label": "Name", "value": "name"},
{"label": "Created On", "value": "creation"},
{"label": "Last Modified", "value": "modified"},
{"label": "Modified By", "value": "modified_by"},
{"label": "Owner", "value": "owner"},
{"label": "Name", "fieldname": "name"},
{"label": "Created On", "fieldname": "creation"},
{"label": "Last Modified", "fieldname": "modified"},
{"label": "Modified By", "fieldname": "modified_by"},
{"label": "Owner", "fieldname": "owner"},
]

for field in standard_fields:
field["label"] = _(field["label"])
field["value"] = field["fieldname"]
fields.append(field)

return fields
Expand Down Expand Up @@ -100,6 +102,7 @@ def get_filterable_fields(doctype: str):

for field in res:
field["label"] = _(field.get("label"))
field["value"] = field.get("fieldname")

return res

Expand Down Expand Up @@ -129,23 +132,23 @@ def get_group_by_fields(doctype: str):
fields = [
{
"label": _(field.label),
"value": field.fieldname,
"fieldname": field.fieldname,
}
for field in fields
if field.label and field.fieldname
]

standard_fields = [
{"label": "Name", "value": "name"},
{"label": "Created On", "value": "creation"},
{"label": "Last Modified", "value": "modified"},
{"label": "Modified By", "value": "modified_by"},
{"label": "Owner", "value": "owner"},
{"label": "Liked By", "value": "_liked_by"},
{"label": "Assigned To", "value": "_assign"},
{"label": "Comments", "value": "_comments"},
{"label": "Created On", "value": "creation"},
{"label": "Modified On", "value": "modified"},
{"label": "Name", "fieldname": "name"},
{"label": "Created On", "fieldname": "creation"},
{"label": "Last Modified", "fieldname": "modified"},
{"label": "Modified By", "fieldname": "modified_by"},
{"label": "Owner", "fieldname": "owner"},
{"label": "Liked By", "fieldname": "_liked_by"},
{"label": "Assigned To", "fieldname": "_assign"},
{"label": "Comments", "fieldname": "_comments"},
{"label": "Created On", "fieldname": "creation"},
{"label": "Modified On", "fieldname": "modified"},
]

for field in standard_fields:
Expand Down Expand Up @@ -197,7 +200,7 @@ def get_quick_filters(doctype: str):
)

if doctype == "CRM Lead":
quick_filters = [filter for filter in quick_filters if filter.get("name") != "converted"]
quick_filters = [filter for filter in quick_filters if filter.get("fieldname") != "converted"]

return quick_filters

Expand Down Expand Up @@ -344,7 +347,7 @@ def get_data(
for kc in kanban_columns:
column_filters = {column_field: kc.get("name")}
order = kc.get("order")
if (column_field in filters and filters.get(column_field) != kc.name) or kc.get("delete"):
if (column_field in filters and filters.get(column_field) != kc.get("name")) or kc.get("delete"):
column_data = []
else:
column_filters.update(filters.copy())
Expand Down Expand Up @@ -392,32 +395,32 @@ def get_data(
fields = [
{
"label": _(field.label),
"type": field.fieldtype,
"value": field.fieldname,
"fieldtype": field.fieldtype,
"fieldname": field.fieldname,
"options": field.options,
}
for field in fields
if field.label and field.fieldname
]

std_fields = [
{"label": "Name", "type": "Data", "value": "name"},
{"label": "Created On", "type": "Datetime", "value": "creation"},
{"label": "Last Modified", "type": "Datetime", "value": "modified"},
{"label": "Name", "fieldtype": "Data", "fieldname": "name"},
{"label": "Created On", "fieldtype": "Datetime", "fieldname": "creation"},
{"label": "Last Modified", "fieldtype": "Datetime", "fieldname": "modified"},
{
"label": "Modified By",
"type": "Link",
"value": "modified_by",
"fieldtype": "Link",
"fieldname": "modified_by",
"options": "User",
},
{"label": "Assigned To", "type": "Text", "value": "_assign"},
{"label": "Owner", "type": "Link", "value": "owner", "options": "User"},
{"label": "Like", "type": "Data", "value": "_liked_by"},
{"label": "Assigned To", "fieldtype": "Text", "fieldname": "_assign"},
{"label": "Owner", "fieldtype": "Link", "fieldname": "owner", "options": "User"},
{"label": "Like", "fieldtype": "Data", "fieldname": "_liked_by"},
]

for field in std_fields:
if field.get("value") not in rows:
rows.append(field.get("value"))
if field.get("fieldname") not in rows:
rows.append(field.get("fieldname"))
if field not in fields:
field["label"] = _(field["label"])
fields.append(field)
Expand Down Expand Up @@ -451,12 +454,12 @@ def get_options(type, options):
return options

for field in fields:
if field.get("value") == group_by_field:
if field.get("fieldname") == group_by_field:
group_by_field = {
"label": field.get("label"),
"name": field.get("value"),
"type": field.get("type"),
"options": get_options(field.get("type"), field.get("options")),
"fieldname": field.get("fieldname"),
"fieldtype": field.get("fieldtype"),
"options": get_options(field.get("fieldtype"), field.get("options")),
}

return {
Expand Down
4 changes: 2 additions & 2 deletions crm/fcrm/doctype/crm_exotel_settings/crm_exotel_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"depends_on": "enabled",
"fieldname": "record_call",
"fieldtype": "Check",
"label": "Record Call"
"label": "Record Outgoing Calls"
},
{
"fieldname": "column_break_qwfn",
Expand All @@ -96,7 +96,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2025-01-20 15:00:51.096985",
"modified": "2025-01-22 19:54:20.074393",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Exotel Settings",
Expand Down
3 changes: 3 additions & 0 deletions crm/integrations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def get_contact_by_phone_number(phone_number):


def get_contact(phone_number, exact_match=False):
if not phone_number:
return {"mobile_no": phone_number}

cleaned_number = (
phone_number.strip()
.replace(" ", "")
Expand Down
2 changes: 1 addition & 1 deletion frappe-ui
2 changes: 1 addition & 1 deletion frontend/src/components/Activities/NoteArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ async function deleteNote(name) {
doctype: 'FCRM Note',
name,
})
notes.reload()
notes.value?.reload()
}
</script>
24 changes: 7 additions & 17 deletions frontend/src/components/Filter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,7 @@ const list = defineModel()
const filterableFields = createResource({
url: 'crm.api.doc.get_filterable_fields',
cache: ['filterableFields', props.doctype],
params: {
doctype: props.doctype,
},
transform(fields) {
fields = fields.map((field) => {
return {
label: field.label,
value: field.fieldname,
...field,
}
})
return fields
},
params: { doctype: props.doctype },
})

onMounted(() => {
Expand Down Expand Up @@ -447,26 +435,28 @@ function setfilter(data) {
filters.value.add({
field: {
label: data.label,
fieldname: data.value,
fieldname: data.fieldname,
fieldtype: data.fieldtype,
options: data.options,
},
fieldname: data.value,
fieldname: data.fieldname,
operator: getDefaultOperator(data.fieldtype),
value: getDefaultValue(data),
})
apply()
}

function updateFilter(data, index) {
if (!data.fieldname) return

filters.value.delete(Array.from(filters.value)[index])
filters.value.add({
fieldname: data.value,
fieldname: data.fieldname,
operator: getDefaultOperator(data.fieldtype),
value: getDefaultValue(data),
field: {
label: data.label,
fieldname: data.value,
fieldname: data.fieldname,
fieldtype: data.fieldtype,
options: data.options,
},
Expand Down
11 changes: 5 additions & 6 deletions frontend/src/components/GroupBy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ const list = defineModel()

const groupByValue = ref({
label: '',
value: '',
fieldname: '',
})

const groupByOptions = createResource({
url: 'crm.api.doc.get_group_by_fields',
cache: ['groupByOptions', props.doctype],
params: {
doctype: props.doctype,
},
params: { doctype: props.doctype },
})

onMounted(() => {
Expand All @@ -62,16 +60,17 @@ onMounted(() => {
})

function setGroupBy(data) {
if (!data?.fieldname) return
groupByValue.value = data
nextTick(() => emit('update', data.value))
nextTick(() => emit('update', data.fieldname))
}

const options = computed(() => {
if (!groupByOptions.data) return []
if (!list.value?.data?.group_by_field) return groupByOptions.data
groupByValue.value = list.value.data.group_by_field
return groupByOptions.data.filter(
(option) => option !== groupByValue.value.value
(option) => option.fieldname !== groupByValue.value.fieldname,
)
})
</script>
12 changes: 5 additions & 7 deletions frontend/src/components/SortBy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ const list = defineModel()
const sortOptions = createResource({
url: 'crm.api.doc.sort_options',
cache: ['sortOptions', props.doctype],
params: {
doctype: props.doctype,
},
params: { doctype: props.doctype },
})

onMounted(() => {
Expand Down Expand Up @@ -228,7 +226,7 @@ const options = computed(() => {
const selectedOptions = [...sortValues.value].map((sort) => sort.fieldname)
restartSort()
return sortOptions.data.filter((option) => {
return !selectedOptions.includes(option.value)
return !selectedOptions.includes(option.fieldname)
})
})

Expand All @@ -242,13 +240,13 @@ function getSortLabel() {
if (!sortValues.value.size) return __('Sort')
let values = Array.from(sortValues.value)
let label = sortOptions.data?.find(
(option) => option.value === values[0].fieldname,
(option) => option.fieldname === values[0].fieldname,
)?.label
return label || values[0].fieldname
}

function setSort(data) {
sortValues.value.add({ fieldname: data.value, direction: 'asc' })
sortValues.value.add({ fieldname: data.fieldname, direction: 'asc' })
restartSort()
apply()
}
Expand All @@ -257,7 +255,7 @@ function updateSort(data, index) {
let oldSort = Array.from(sortValues.value)[index]
sortValues.value.delete(oldSort)
sortValues.value.add({
fieldname: data.value,
fieldname: data.fieldname,
direction: oldSort.direction,
})
apply()
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/ViewControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ const viewsDropdownOptions = computed(() => {
})

const quickFilterList = computed(() => {
let filters = [{ name: 'name', label: __('ID') }]
let filters = [{ fieldname: 'name', fieldtype: 'Data', label: __('ID') }]
if (quickFilters.data) {
filters.push(...quickFilters.data)
}
Expand All @@ -608,8 +608,10 @@ const quickFilterList = computed(() => {
)
return
filter['value'] = value[1]?.replace(/%/g, '')
} else if (typeof value == 'boolean') {
filter['value'] = value
} else {
filter['value'] = value.replace(/%/g, '')
filter['value'] = value?.replace(/%/g, '')
}
}
})
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/pages/Deals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function getRow(name, field) {
const rows = computed(() => {
if (!deals.value?.data?.data) return []
if (deals.value.data.view_type === 'group_by') {
if (!deals.value?.data.group_by_field?.name) return []
if (!deals.value?.data.group_by_field?.fieldname) return []
return getGroupedByRows(
deals.value?.data.data,
deals.value?.data.group_by_field,
Expand All @@ -348,9 +348,9 @@ function getGroupedByRows(listRows, groupByField, columns) {
let filteredRows = []

if (!option) {
filteredRows = listRows.filter((row) => !row[groupByField.name])
filteredRows = listRows.filter((row) => !row[groupByField.fieldname])
} else {
filteredRows = listRows.filter((row) => row[groupByField.name] == option)
filteredRows = listRows.filter((row) => row[groupByField.fieldname] == option)
}

let groupDetail = {
Expand All @@ -359,7 +359,7 @@ function getGroupedByRows(listRows, groupByField, columns) {
collapsed: false,
rows: parseRows(filteredRows, columns),
}
if (groupByField.name == 'status') {
if (groupByField.fieldname == 'status') {
groupDetail.icon = () =>
h(IndicatorIcon, {
class: getDealStatus(option)?.color,
Expand Down
Loading
Loading