I can't send email by role in Notification AttributeError: ‘Meta’ object has no attribute ‘permissions’

Hi
So here is error

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/notification/notification.py”, line 283, in evaluate_alert
alert.send(doc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/notification/notification.py”, line 119, in send
self.send_an_email(doc, context)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/notification/notification.py”, line 135, in send_an_email
recipients = self.get_list_of_recipients(doc, context)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/notification/notification.py”, line 174, in get_list_of_recipients
emails = get_emails_from_role(recipient.email_by_role)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/role/role.py”, line 30, in get_emails_from_role
fields=[“parent”])
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1235, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 87, in execute
result = self.build_and_run()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 99, in build_and_run
args = self.prepare_args()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 118, in prepare_args
self.build_conditions()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 292, in build_conditions
match_conditions = self.build_match_conditions()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 438, in build_match_conditions
role_permissions = frappe.permissions.get_role_permissions(meta, user=self.user)
File “/home/frappe/frappe-bench/apps/frappe/frappe/permissions.py”, line 164, in get_role_permissions
applicable_permissions = list(filter(is_perm_applicable, doctype_meta.permissions))
AttributeError: ‘Meta’ object has no attribute ‘permissions’

Hi and welcome to ERNext!

Are you self hosted and if so what version?

Screenshot%20from%202018-08-23%2010-31-08

Yes, Here is my version
I think it because it run on localhost

Similar error noted here AttributeError: 'Meta' object has no attribute 'permissions'

And reported here AttributeError: 'Meta' object has no attribute 'permissions' · Issue #15130 · frappe/erpnext · GitHub to be fixed

A wild guess possibly a result of this caching change to develop two weeks ago optimize(meta): meta is now cached in redis by rmehta · Pull Request #5948 · frappe/frappe · GitHub

read about it here too [Performance] 1 Sales Invoice Save makes ~700+ DB calls. ~1000+ DB calls on Submit - #28 by jpp

I strongly suspect you’re right. I’m getting the same error, but if I clear the cash the next notification works fine, then subsequent notifications (until I clear the cache again) go back to failing with the error message above.

“if I clear the cash the next notification works fine, then subsequent notifications (until I clear the cache again) go back to failing with the error message above”

That’s good info! nabin closed issue # 15130 a few days ago with no note why. If an update does not fix your error I suggest re-open that issue and add this thread to the discussion.

That’s a very good call. I’ll test it out as soon as the next release comes out and report back here.