refactor: replace json.loads with frappe.parse_json for assignees in remove_assignments function
(cherry picked from commit 5010cccc7158dca670530c564a4a4b01067e090f)
This commit is contained in:
parent
7e53e0f4e4
commit
8c3733a212
@ -662,7 +662,7 @@ def get_fields_meta(doctype, restricted_fieldtypes=None, as_array=False, only_re
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def remove_assignments(doctype, name, assignees, ignore_permissions=False):
|
def remove_assignments(doctype, name, assignees, ignore_permissions=False):
|
||||||
assignees = json.loads(assignees)
|
assignees = frappe.parse_json(assignees)
|
||||||
|
|
||||||
if not assignees:
|
if not assignees:
|
||||||
return
|
return
|
||||||
|
|||||||
@ -99,7 +99,6 @@ const oldAssignees = ref([])
|
|||||||
const assignToMe = ref(false)
|
const assignToMe = ref(false)
|
||||||
|
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
const ownerRemoved = ref(false)
|
|
||||||
|
|
||||||
const { users, getUser } = usersStore()
|
const { users, getUser } = usersStore()
|
||||||
|
|
||||||
@ -143,7 +142,6 @@ watch(assignToMe, (val) => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.open,
|
() => props.open,
|
||||||
(val) => {
|
(val) => {
|
||||||
ownerRemoved.value = false
|
|
||||||
if (val) {
|
if (val) {
|
||||||
oldAssignees.value = [...(assignees.value || [])]
|
oldAssignees.value = [...(assignees.value || [])]
|
||||||
|
|
||||||
@ -170,15 +168,10 @@ async function updateAssignees() {
|
|||||||
.map((assignee) => assignee.name)
|
.map((assignee) => assignee.name)
|
||||||
|
|
||||||
if (removedAssignees.length) {
|
if (removedAssignees.length) {
|
||||||
if (!ownerRemoved.value && removedAssignees.includes(owner.value)) {
|
|
||||||
ownerRemoved.value = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await call('crm.api.doc.remove_assignments', {
|
await call('crm.api.doc.remove_assignments', {
|
||||||
doctype: props.doctype,
|
doctype: props.doctype,
|
||||||
name: props.doc.name,
|
name: props.doc.name,
|
||||||
assignees: JSON.stringify(removedAssignees),
|
assignees: removedAssignees,
|
||||||
})
|
})
|
||||||
toast.success(__('Assignees removed successfully.'))
|
toast.success(__('Assignees removed successfully.'))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user