تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
1308 أدوات العرض

I have one model name sales.target and another three model name month.target.line, quarter.target.line and year.target.line

 

And in sales.target model I've three one2many field for above specified model:
yearly_target_ids = fields.One2many('year.target.line', 'sales_target_id', string="Yearly Target")
quarter_target_ids = fields.One2many('quarter.target.line', 'sales_target_id', string='Quarterly Target',store=True , readonly=False)
month_target_ids = fields.One2many('month.target.line', 'sales_target_id',string='Month',store=True,readonly=False)

 


I've used this fields in compute function also.

 

And my access rights are defined like below:
access_sales_target_manager,access_sales_target_manager,model_sales_target,sales_team.group_sale_manager,1,1,1,1
access_sales_target_manager_3,access_sales_target_manager_3,model_month_target_line,sales_team.group_sale_manager,1,1,1,1
access_sales_target_manager_8,access_sales_target_manager_8,model_year_target_line,sales_team.group_sale_manager,1,1,1,1
access_sales_target_manager_1,access_sales_target_manager_1,model_quarter_target_line,sales_team.group_sale_manager,1,1,1,1
access_sales_target_salesman,access_sales_target_salesman,model_sales_target,sales_team.group_sale_salesman,1,0,0,0
access_sales_target_salesman_1,access_sales_target_salesman_1,model_quarter_target_line,sales_team.group_sale_salesman,1,0,0,0
access_sales_target_salesman_3,access_sales_target_salesman_3,model_month_target_line,sales_team.group_sale_salesman,1,0,0,0
access_sales_target_salesman_8,access_sales_target_salesman_8,model_year_target_line,sales_team.group_sale_salesman,1,0,0,0

 


When I access this menu from salesman group user, It is giving access error mentioned in screenshot

https://i.imgur.com/jGzSXch.png

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

The access right warning says that the only user group allowed to access sale.target model is Sales/Admin , so if you need this to be accessed by the sale users, you have to grand the permission for this group of users to this model.


If you used this field inside a compute function, try settings compute_sudo=True along with the field in the python and see.


Thanks

الصورة الرمزية
إهمال
الكاتب

Hello,
Niyas Raphy
I have tried your solution but it didn't work
can you give another solution or approach
yearly_target_ids = fields.One2many('year.target.line', 'sales_target_id', string="Yearly Target", compute_sudo=True)
quarter_target_ids = fields.One2many('quarter.target.line', 'sales_target_id', string='Quarterly Target',store=True , readonly=False, compute_sudo=True)
month_target_ids = fields.One2many('month.target.line', 'sales_target_id',string='Month',store=True,readonly=False, compute_sudo=True)

I've tried like this, but It didn't work for me. I want give only read access to sale_team.group_sale_salesman.

did you upgrade your module after adding compute_sudo ?

الكاتب

yes, I upgrade the module.