Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
3799 มุมมอง

How can I make a user role - Project Manager or User statement for a function?

like this :

def onchange_planned(self, cr, uid, ids, planned=0.0, effective=0.0):

if user_id.sel_groups_44_45 == 45:

return {'value': {'remaining_hours': planned - effective}}


But it doesn't work.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Wizardz,

You should check if particular group is assigned to current logged in user to fulfill your requirement.

if self.pool.get('res.users').has_group(cr, uid, 'module_name.XML_ID_of_group'): # return True if group is assigned to user, False otherwise
#your logic goes here if user exists in the group

Source Code 

Hope this help you.

อวตาร
ละทิ้ง
ผู้เขียน

I don't wanna get the group, In the settings per user in Project, you can choose from manager and user. I wanna set a if the user is a user in projcect, or a manager

ผู้เขียน

or is it like this the ID from the group xml : if self.pool.get('res.users').has_group(cr, uid, 'res.groups.84'):

You can apply groups on planned_hours field. Users who are not in that group, won't be able to see the field.

ผู้เขียน

and how? please

ผู้เขียน คำตอบที่ดีที่สุด

If I do this: 

    def onchange_planned(self, cr, uid, ids, planned=0.0, effective=0.0):

if self.pool.get('res.users').has_group(cr, uid, 'project.group_project_manager'): # return True if group is assigned to user, False otherwise
#your logic goes here if user exists in the group
return {'value': {'remaining_hours': planned - effective}}
raise osv.except_osv(('Info'), ('You are not available to change the planned time settings.'))


Other user get the raise info message but can change the planned_hours. Why? How Can I stop that a user not in this group can't CHANGE the planned hours??????? 

อวตาร
ละทิ้ง
ผู้เขียน

How can I stop that the value I put in is going to save?

Related Posts ตอบกลับ มุมมอง กิจกรรม
7
พ.ค. 20
6413
0
เม.ย. 16
3077
2
เม.ย. 15
5975
Hide field in a tree view แก้ไขแล้ว
11
ก.ย. 21
32163
Group by on field of a related model. แก้ไขแล้ว
2
ม.ค. 24
15041