İç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 remove user from multiple groups at once Odoo 12

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
usergroupsodooodoo12
2 Cevaplar
7509 Görünümler
Avatar
Pawan Kumar Sharma

Hello All,

I want to remove the user from multiple groups at once when changing from an 'individual' to 'company' on write method of a contact form.

@api.multi
def write(self, values):
user = self.env['res.users'].search([('partner_id', '=', self.id)])
if 'company_type' in values:
if values["company_type"] == "company":
# want to add in below group
"""[(6, 0, [self.env.ref('base.group_user').id,
self.env.ref('sales_team.group_sale_salesman_all_leads').id,
self.env.ref('survey.group_survey_manager').id
])]"""

# want to remove from below group
"""[(6, 0, [self.env.ref('base.group_portal').id,
self.env.ref('survey.group_survey_user').id,
])]"""
res = super(Contact, self).write(values)
return res

Thanks in advance

1
Avatar
Vazgeç
Avatar
Malay Khamar (Serpent Consulting Services Pvt. Ltd.)
En İyi Yanıt

Hello,

You can try this,

@api.multi
def write(self, values):
    user = self.env['res.users'].search([('partner_id', '=', self.id)])
    if 'company_type' in values:
        if values["company_type"] == "company":
            # want to add in below group
            user.write({'groups_id': [(4, self.env.ref('base.group_user').id),
                                                    (4, self.env.ref('sales_team.group_sale_salesman_all_leads').id),
                                                    (4, self.env.ref('survey.group_survey_manager').id)
                                                       ]})
            # want to remove from below group
           user.write({'groups_id': [(3, self.env.ref('base.group_portal').id),
                                                    (3, self.env.ref('survey.group_survey_user').id),
                                                        ]})
    res = super(Contact, self).write(values)
    return res


You can also use like this:

    user.write({'groups_id': [(4, self.env.ref('base.group_user').id),
                                            (4, self.env.ref('sales_team.group_sale_salesman_all_leads').id),
                                            (4, self.env.ref('survey.group_survey_manager').id),
                                            (3, self.env.ref('base.group_portal').id),
                                            (3, self.env.ref('survey.group_survey_user').id),
                                           ]})
​


Hope this will work for you,

Thanks

8
Avatar
Vazgeç
Pawan Kumar Sharma
Üretici

Thanks Malay, it's working fine

Avatar
Avinash Nk
En İyi Yanıt
Hello Pawan,

To remove a user from a group, you can do it like this

your_group = self.env.ref('module.odoo_group', False)
your_group.write({'users': [(3, user_id)]})

For Adding,
 your_group = self.env.ref('module.odoo_group', False) 
 your_group.write({'users': [(4, user_id)]})
You can use loop and your logic to execute all at once.

Check this for more understanding, how to write to a One2many field.
(0, 0, { values }) 
link to a new record that needs to be created with the 
given values dictionary
(1, ID, { values }) 
update the linked record with id = ID (write values on it)
(2, ID) 
remove and delete the linked record with id = ID 
(calls unlink on ID, that will delete the object completely, 
and the link to it as well)
(3, ID) 
cut the link to the linked record with id = ID 
(delete the relationship between the two objects but does 
not delete the target object itself)
(4, ID) 
link to existing record with id = ID (adds a relationship)
(5) 
unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs]) 
replace the list of linked IDs (like using (5) then (4,ID) 
for each ID in the list of IDs)




Thanks & Regards
Avinash N K

1
Avatar
Vazgeç
Pawan Kumar Sharma
Üretici

Thanks avinash, it's working

Avinash Nk

My pleasure

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
Odoo Users Creation
user odoo
Avatar
Avatar
1
Kas 23
2145
How to track One2many field in Odoo12? Çözüldü
odoo odoo12
Avatar
Avatar
Avatar
Avatar
3
Kas 23
18409
Error: Couldn't load module web Çözüldü
odoo odoo12
Avatar
Avatar
Avatar
3
Kas 24
26504
How I get the current ID of a record ? Çözüldü
odoo odoo12
Avatar
Avatar
1
Nis 23
6898
Binary field as attachment in mail in Odoo 13 Çözüldü
odoo odoo12
Avatar
Avatar
2
Ara 22
7783
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