Notifications in custom app

Hi guys,
I’m trying to customize the notifications for the leave application in my custom app, I made a notification function and call it in my notifications file as such:

def get_notification_config():
return {
“for_doctype”: {
‘Leave Application’:‘mycustomApp.notifications.leave_application_notification_count’
}
}
and it raises me an error which is

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 57, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 923, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/notifications.py”, line 255, in get_open_count
filters[fieldname] = name
TypeError: ‘unicode’ object does not support item assignment

So what I’m missing guys??

1 Like

@random.1 I don’t know what the function leave_application_notification_count is returning but it should be like this:

def get_notification_config():
    notifications = {
        "for_doctype": {
            "Coupons": {
                "status": ("in", ("Open", "Overdue"))
            },
            "Cheques": {
                "status": "Open"
            },
        }
    }

    doctype = [d for d in notifications.get('for_doctype')]
    for doc in frappe.get_all(
            'DocType',
            fields=["name"],
            filters={"name": ("not in", doctype),
                     'is_submittable': 1}):
        notifications["for_doctype"][doc.name] = {"docstatus": 0}

    return notifications

I think he mean using function instead of filters like frappe notifications

I created a new app in a new instance the error in one function in the file get_open_count

it does not test if the filter is not a dictionary.
it assumes that all references of the filter are dictionary.
I think you should make an issue with it.
best regards

1 Like