İç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

Many2many field filtering based on selected contact id?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
domainmany2manyodoo10
1 Cevapla
11967 Görünümler
Avatar
Samo Arko

I'm trying to get projects where the selected contact is the follower. I need it so I can select for which projects I should generate the report. For this I'm using a wizard with a Many2One field for selecting the contact and a Many2many field I want to use for checkboxes in the view.

Is it possible to set a dynamic domain that will filter the Many2many field?

contact_id = fields.Many2one('res.partner', domain="[('customers_tic_id', '!=', False)]")
project_ids = fields.Many2many(comodel_name='project.project',
                                   relation='project_document_wizard_rel',
                                   column1='document_wizard_id',
                                   column2='project_id',
                                   string='Contacts following projects',
                                   domain="[('project_id', 'in', self.followers_search_to_list())]")




def followers_search_to_list(self):
        tmp_list = list()
        followers = self.env['mail.followers'].sudo().search([('partner_id', '=', contact_id.id), ('res_model', '=', 'project.project')])

        for follower in followers:
            tmp_list.append(follower.res_id)

        return tmp_list

So what I'm doing wrong?

0
Avatar
Vazgeç
Avatar
Ibrahim Boudmir
En İyi Yanıt

Hi, 

Your question is : can we set a dynamic domain that will filter M2M field based on Another M2O field? 

Answer : Yes you can. 

First, remove the domain from the M2M declaration. Then add a onchange function like this:

@api.onchange('contact_id')
 _onchange_contact_id(self):
    if self.contact_id:
        domain = [('project_id', 'in', self.followers_search_to_list())]
        return {'domain': {'project_ids': domain}}

Upvote if this helps. If not, you can write back for further analysis.
Regards.
5
Avatar
Vazgeç
Samo Arko
Üretici

Thanks! I only needed to change 'project_id' to 'id'. And you forgot to say that I needed to add compute='_on_change_contact_id' to M2M field. Is there a way to not show any M2M records until the contact is selected? Now I get all existing projects until I select the contact.

Samo Arko
Üretici

I can't click on any of the checkboxes!?

Ibrahim Boudmir

Hi,

1- I did not forget to mention that the field should have compute attribute because simply it should not.

2- Not show M2M record until contact is selected : in onchange_contact_id, i only added the condition where contact is set. In this case, you can add 'else' then apply another domain that suits your need.

3- you can't click on any of the checkboxes because you made the field compute... compute field is readonly. Since that is not what i suggested, remove compute attribute.

but to enlighten you more, even if a field is computed, you can still add records manually by adding the attribute "inverse".

Hope this helps you.

Samo Arko
Üretici

yeah I figured that about compute field out, so I removed it and it saves. But the problem that I've got now is when the record is saved and when I open it again (go to a different view and back) there are again displayed all projects. But at least the ones that were selected remain selected.

Vysakh B Thottarath

@Tabla : I also have the same problem while using onchange for domain.You got any other solutions ?

Samo Arko
Üretici

You need to specify the problem a bit more. But mostly the solution suggested worked for me. If you created a post with the problem explained and some code then post me the link in the comment.

Yeison X

Hi.

Can I do this with Automated Actions?

I have a many2one field (res.partner) and a many2many field (account.move)

When I select the partner, I want only to show the account move documents related with the partner selected.

I'm wondering if it's possible to achieve this with a automated actions and a python code.

Thanks

ahmadsalih7

Thank you, it works !!

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
Many2many domain works when click search more but wrong values in dropdown
domain many2many
Avatar
0
Kas 22
80
[SOLVED] Create rule using many2many - how to? Çözüldü
domain many2many
Avatar
1
Haz 22
8121
Many2many domain not working Çözüldü
domain many2many
Avatar
1
Tem 21
3524
Many2many domain not working Çözüldü
domain many2many
Avatar
Avatar
1
Tem 21
5032
How to Update Many2Many Relation Table Records in Odoo 10 Çözüldü
many2many odoo10
Avatar
Avatar
2
May 17
11862
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