İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

How to know if the current user is in a certain group

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
v8environmentmodel
4 Cevaplar
68356 Görünümler
Avatar
Luis Miguel Valenzuela

I'm building a custom module in which I inherited res.partner. I want certain functionalities of my inherit res.partner  to be available for certain user group, how in partner.py, might I find to which groups the current user is part of ?

I've tried to use a field with a Many2one ('res.groups', domain = ('user', 'in', ??????)) but don't know how to use in this domain the current user.

Thanks in advance

0
Avatar
Vazgeç
Sehrish

check this: https://learnopenerp.blogspot.com/2017/10/how-to-check-login-user-group-in-odoo.html

Avatar
Atchuthan - Technical Consultant, Sodexis Inc
En İyi Yanıt

If you need to control the method based on the group, then you can try this

flag = self.pool.get('res.users').has_group(cr, uid, 'base.group_sale_manager') 

If user has this group access then flag is TRUE else FALSE

Here,
uid --> User ID that needs to be checked
base.group_sale_manager --> XML id of the group that needs to be checked
13
Avatar
Vazgeç
Omar Sebastian Ayala Mendez

how to get the value of cr?

Avatar
Ankit H Gandhi(AHG)
En İyi Yanıt

Hello

for version 11, you can use below code.

to check if the use has a group_base try this :

if self.env.user.has_group('base.group_user') :

Hope this help you.

Best Thanks,

Ankit H Gandhi.

6
Avatar
Vazgeç
Avatar
Vivek
En İyi Yanıt

I think you need something like : You have created one many2one field for Groups. In which, you want to list number of groups only that assign with current login user. Right? If yes, then I can suggest one way to you

First, you need to make one function field like group_ids in your current model. Then you have to set all groups of current login user in that field. Then you can use that field in domain.

Here is the example for function field (.py file)

def _get_user_groups(self,cr,uid,ids,fields,arg,context={}):

    res = dict.fromkeys(ids,[])

    user = self.pool.get('res.users').browse(cr,uid,uid)

    for partner in self.browse(cr,uid,ids):

        user_group_ids = map(int,user.groups_id)

        res[partner.id] = user_group_ids

    return res

_columns={

                    'group_ids':fields.function(_get_user_groups,type='many2many',relation='res.groups',

                        string='Groups'),

                    }

def _get_default_user_groups(self,cr,uid,context={}):

    user = self.pool.get('res.users').browse(cr,uid,uid)

    user_group_ids = map(int,user.groups_id)

    return user_group_ids

_defaults={

                    'group_ids':_get_default_user_groups,

                }

You must use _defaults because function field value set after record is save. So, at a time to create new record, if you don't use _defaults for group_ids field, there will not any group is set in this field.

 

In xml file you need to add field like :

<field name="group_ids" invisible="1" />

<field name="group_id" string="Group" domain="[('id','in',group_ids[0][2])]">

0
Avatar
Vazgeç
Avatar
Anatole
En İyi Yanıt

here is something more recent wich work for me :

ack_workflows = name of my module
group_manager = my group name
generate_project_task() = my method name
@api.multi
def generate_task_action(self):
# On test l'appartenance au groupe
flag = self.env['res.users'].has_group('ack_workflows.group_manager')
if flag:
order.generate_project_task()
else:
raise UserError('Vous n\'avez pas les droits pour réaliser cette action')

very good link for the security : 
 https://www.odoo.yenthevg.com/creating-security-groups-odoo/
import for raise UserError :
from odoo.exceptions import UserError
I hope it useful

0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
How do you implement the Associations: Members website module? Çözüldü
v8
Avatar
Avatar
Avatar
3
Tem 25
9783
How to Integrate a Full-Screen Color Testing Tool with Odoo Website Builder?
v8
Avatar
Avatar
1
May 25
2017
What's the difference between sale_order and sale_order_line? Çözüldü
model
Avatar
Avatar
Avatar
Avatar
3
Kas 24
31617
Odoo V8 integrate with Microsoft O365 Email
v8
Avatar
0
Oca 24
2608
What is the use of __init__() and init() in odoo ?When We can use them ? Çözüldü
v8
Avatar
Avatar
1
Şub 22
25124
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now