Query Report - Permitted Documents For User

159 views
Skip to first unread message

MP

unread,
Aug 5, 2014, 12:02:16 PM8/5/14
to erpnext-dev...@googlegroups.com
Hi Team.

Is there any reason why Department doctype is not available for selection under doctype field on "Permitted Documents For User" report page? This is happening on the site that has been migrated from ERPnext V3 to V4. Let me know if you need further information.

Kind regards,
Mayur Patel

Anand Doshi

unread,
Aug 6, 2014, 1:18:29 AM8/6/14
to ERPNext Developer's Forum
Hi Mayur,

Go to Role Permissions Manager and check if a role you have has read permissions on Department DocType.

-Anand.


--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/16b18fc1-114f-442f-9853-c4a8c4006b4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

MP

unread,
Aug 6, 2014, 6:31:12 AM8/6/14
to erpnext-dev...@googlegroups.com

 

Hi Anand,

I am logged in as Administrator user (it has System Manager role). Should I be checking if this Administrator user has read permission for Department DocType? If so, it seems that the Administrator users (with System Manager role) doesn't have any permission for Department Doctype. See below screen shot. The migration script didn't seems to have correctly migrated over all the permission for Department Doctype. This may be an issue with other doctype too?

Before migration from version 3:
http://imgur.com/jUKQnoZ

After migration in version 4:

http://imgur.com/kQh1ds5

Anand Doshi

unread,
Aug 6, 2014, 6:36:32 AM8/6/14
to ERPNext Developer's Forum
Hi Mayur,

Make sure you add All Roles to Administrator User and you should be fine.

-Anand.


--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.

MP

unread,
Aug 6, 2014, 6:51:22 AM8/6/14
to erpnext-dev...@googlegroups.com
Hi Anand,

Thanks for your reply.

I am getting this error http://imgur.com/3zJweRE when trying to assign all roles to Administrator users. I don't see any error in either web console log or server console log.

Also what about the fact that 'HR Manager' Role used to have certain permissions for Department Doctype before migration but after migration it is not there?

Kind regards,
Mayur Patel

Anand Doshi

unread,
Aug 6, 2014, 7:15:12 AM8/6/14
to ERPNext Developer's Forum
Hi Mayur,

With new permission system, we have also removed certain redundant permissions like HR Manager will always have HR User role and consequently will be able to see Department record, etc.

It seems that your database has some dirty Roles records.

Run this query in your database to get rid of them:
delete from `tabUserRole` where ifnull(role, '')=''

Thanks,
Anand.


--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.

MP

unread,
Aug 6, 2014, 7:44:05 AM8/6/14
to erpnext-dev...@googlegroups.com
Thanks Anand,

Sorry for too many questions.

1. Regarding your comment about "With new permission system, we have also removed certain redundant permissions like HR Manager will always have HR User role and consequently will be able to see Department record, etc.". If this is the case then it seems that the migration process hasn't take care of it. For example, few  users have been only assigned "HR Manager" role in old version, but after migration, they still have "HR Manager" permission and also not "HR User" permission (automatically assigned by the migration process). So it seems that they are not going to see Department records as only "HR User" role has the permission over it. Does migration script suppose to be take care of it or this needs to be done manually as part of the migration?


2. Running the above delete sql query, deleted 1 row. After that I was able to assigned All roles except for Employee role to the Administrator user. I am getting this message   http://imgur.com/lUv6Vy2 when I go to "Query Report - Permitted Documents For User" page.I am assuming that this is just asking me to enter appropriate detail before running the report?

3. I am getting this message http://imgur.com/3IJwKpo  and below error in web console when I enter "Department" in DocType field and select a user on "Query Report - Permitted Documents For User" page. I am logged in as Administrator user. I am assuming that I am getting this message because the selected user may not have permission over Department doctype? One thing I don't understand is that, for the selected user there is an entry for Department DoctType under "User Permission Manager" so shouldn't he/she should have permission to view that particular Department.

"Traceback (innermost last):
  File "/var/www/frappe-bench/apps/frappe/frappe/app.py", line 51, in application
    response = frappe.handler.handle()
  File "/var/www/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
    execute_cmd(cmd)
  File "/var/www/frappe-bench/apps/frappe/frappe/handler.py", line 84, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 524, in call
    return fn(*args, **newargs)
  File "/var/www/frappe-bench/apps/frappe/frappe/widgets/query_report.py", line 98, in run
    columns, result = frappe.get_attr(method_name)(frappe._dict(filters))
  File "/var/www/frappe-bench/apps/frappe/frappe/core/report/permitted_documents_for_user/permitted_documents_for_user.py", line 16, in execute
    data = frappe.get_list(doctype, fields=fields, as_list=True, user=user)
  File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 593, in get_list
    ignore_permissions=ignore_permissions, user=user)
  File "/var/www/frappe-bench/apps/frappe/frappe/model/db_query.py", line 27, in execute
    raise frappe.PermissionError, self.doctype
 PermissionError: Department
"


Kind regards,
Mayur Patel

Anand Doshi

unread,
Aug 6, 2014, 8:15:20 AM8/6/14
to ERPNext Developer's Forum
Hi Mayur,

Answers below.

Thanks,
Anand.


On Wed, Aug 6, 2014 at 5:14 PM, MP <mayur....@gmail.com> wrote:
Thanks Anand,

Sorry for too many questions.

1. Regarding your comment about "With new permission system, we have also removed certain redundant permissions like HR Manager will always have HR User role and consequently will be able to see Department record, etc.". If this is the case then it seems that the migration process hasn't take care of it. For example, few  users have been only assigned "HR Manager" role in old version, but after migration, they still have "HR Manager" permission and also not "HR User" permission (automatically assigned by the migration process). So it seems that they are not going to see Department records as only "HR User" role has the permission over it. Does migration script suppose to be take care of it or this needs to be done manually as part of the migration?

You will have to manually add HR User role to users with HR Manager role. This was not part of the migration, because we are not aware of the customizations done related to permissions.
 

2. Running the above delete sql query, deleted 1 row. After that I was able to assigned All roles except for Employee role to the Administrator user. I am getting this message   http://imgur.com/lUv6Vy2 when I go to "Query Report - Permitted Documents For User" page.I am assuming that this is just asking me to enter appropriate detail before running the report?
Yes. This is just a validation message.
 

3. I am getting this message http://imgur.com/3IJwKpo  and below error in web console when I enter "Department" in DocType field and select a user on "Query Report - Permitted Documents For User" page. I am logged in as Administrator user. I am assuming that I am getting this message because the selected user may not have permission over Department doctype? One thing I don't understand is that, for the selected user there is an entry for Department DoctType under "User Permission Manager" so shouldn't he/she should have permission to view that particular Department.

"Traceback (innermost last):
  File "/var/www/frappe-bench/apps/frappe/frappe/app.py", line 51, in application
    response = frappe.handler.handle()
  File "/var/www/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
    execute_cmd(cmd)
  File "/var/www/frappe-bench/apps/frappe/frappe/handler.py", line 84, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 524, in call
    return fn(*args, **newargs)
  File "/var/www/frappe-bench/apps/frappe/frappe/widgets/query_report.py", line 98, in run
    columns, result = frappe.get_attr(method_name)(frappe._dict(filters))
  File "/var/www/frappe-bench/apps/frappe/frappe/core/report/permitted_documents_for_user/permitted_documents_for_user.py", line 16, in execute
    data = frappe.get_list(doctype, fields=fields, as_list=True, user=user)
  File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 593, in get_list
    ignore_permissions=ignore_permissions, user=user)
  File "/var/www/frappe-bench/apps/frappe/frappe/model/db_query.py", line 27, in execute
    raise frappe.PermissionError, self.doctype
 PermissionError: Department
"
The error indicates that the user you have selected in Permitted Documents for User does not have read access on Department.

Kind regards,
Mayur Patel

--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.

MP

unread,
Aug 6, 2014, 8:57:31 AM8/6/14
to erpnext-dev...@googlegroups.com
Thanks Anand,

I have added Read permission for the Employee role for Department DocType with "apply user permissions" checkbox ticked. Query Report "Permitted Documents For User" shows the appropriate department for the selected users. But still the leave calendar doesn't shows leave applications for the department. I will follow this up via email.

Kind regards,
Mayur Patel
Reply all
Reply to author
Forward
0 new messages