Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
6740 Widoki

i want to update my field depend on current user's group , but when i execute the method it update all the record even it has the other group .

here's the code :

def wtc_approval(self, cr, uid, ids,vals, context=None):
        user = self.pool.get("res.users").browse(cr, uid, uid)['groups_id']
        data = self.pool.get("wtc.approval.line").browse(cr,uid,user)
        line = self.browse(cr, uid, ids, context=context)
   
        for user in line.app_line:
            line.app_line.write({
                                   'sts':'2',
                                   'pelaksana':uid,
                                   'tanggal':datetime.today()
                                   })
           return True

i don't know how to get current user group , the code always catch all group ..

anybody know how to resolve it ?

Thanks in advance

Awatar
Odrzuć
Najlepsza odpowiedź

You can try to find whether the user has Group access for a particular group.

Flag = self.pool.get('res.users').has_group(cr,create_uid.id , 'base.group_sale_manager')

If access is available, then it is TRUE.

Awatar
Odrzuć
Najlepsza odpowiedź

Openerp has a build in mechanism to restrict access per model / record:

  • Access Control List
  • Record Rule

Generally you can configure access control per model (ex. write access for certain group), openerp will do the checking for you.

The other is condition in workflow transition: you can set group in workflow transition, so that it can be triggered only by that group.

So in many cases you don't have to write some code to check user's group.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
9
mar 20
42056
2
paź 18
3978
1
paź 17
4223
1
mar 15
4662
2
kwi 23
4257