Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

User statement for function

By
wizardz
on 11/11/15, 5:15 AM 601 views

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.

2

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 11/11/15, 6:10 AM

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

wizardz
on 11/11/15, 8:08 AM

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

wizardz
on 11/11/15, 8:10 AM

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

Sudhir Arya (SA)
on 11/12/15, 10:08 AM

and how? please

wizardz
on 11/13/15, 8:48 AM
0
wizardz
On 11/11/15, 10:44 AM

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?

wizardz
on 11/12/15, 3:42 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/11/15, 5:15 AM
Seen: 601 times
Last updated: 11/25/15, 3:19 AM