跳至内容
菜单
此问题已终结
4 回复
22747 查看

hi all,


I have created a new model with two fields and gave permissions too in the CSV file but I am able to access only one field of that model not able to access the second field of that model 

code:


class ChangeUserAssignedd(models.TransientModel):

    _name = 'change.user.assignedd'


    user_id = fields.Many2one('res.users',string="Assigned To")

    project_id = fields.Many2one('project.project',string="Project")


csv file :

access_change_user_assignedd_user,change.user.assignedd,model_change_user_assignedd,base.group_user,1,1,1,1

access_change_user_assignedd_manager,change.user.assignedd,model_change_user_assignedd,base.group_erp_manager,1,1,1,1


i can access user_id field but not the project field when I try to access its showing this error:


Sorry, you are not allowed to access documents of type 'Unknown' (_unknown). No group currently allows this operation. - (Operation: read, User: 2)


 



形象
丢弃
编写者

those objects relation is showing as unknown

Hi Guna,

The problem is dependency error

In your module, manifest file add this in depends,

'depends': ['project']

最佳答案

Hi Guna,

        To access the project.project model in your custom module , you should give access in the csv of your custom module for the user related to that group and as i said don't forget to give depends in your manifest file

access_project_project_bu      project.project      project.model_project_project      base.group_user     1    0    0    0

Check this if you have doubts in creating access rights for custom modules and also inheriting for default modules
https://www.odoo.yenthevg.com/creating-security-groups-odoo/






形象
丢弃
最佳答案

To access the project_id field in the ChangeUserAssignedd model, you need to give the appropriate permissions to the group that you are using. In the CSV file, you have given the permissions for the base.group_user and base.group_erp_manager groups for the user_id field, but not for the project_id field. You need to add another line to the CSV file to give the appropriate permissions for the project_id field for the group that you want to use.

For example, if you want to give read and write access to the project_id field for the base.group_erp_manager group, you can add the following line to the CSV file:

access_change_user_assignedd_manager,change.user.assignedd,field_change_user_assignedd_project,base.group_erp_manager,1,1,1,1

This will give the base.group_erp_manager group read and write access to the project_id field in the ChangeUserAssignedd model. You can adjust the permissions as needed for your use case.

形象
丢弃
最佳答案

This could be also raised by a many2one field without comodel_name attribute set.

In your specific case it's clearly a dependency to module project issue.

形象
丢弃
最佳答案

Does it seem like you created a new model 'TransientModel' which means you are trying to create a wizard object or a normal object?

If trying to create a normal object your need to create a class with 

class ChangeUserAssignedd(models.Model):

If trying to create a wizard object you do not need to provide a CSV file for access rights.

Please take quick look again at your code or explain in details or let me know in case of any further help.

Thanks.

形象
丢弃
相关帖文 回复 查看 活动
2
12月 24
3645
1
11月 24
2334
2
4月 23
16444
1
3月 23
1695
0
12月 21
1965