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

Need help with domain in Many2one field

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
domainpyhtonv17
3 Cevaplar
7862 Görünümler
Avatar
IRIG Events

Hello,


I am struggling a bit with something and I am hoping that somebody here with a lot more experience can help me. 


I am creating a module where I have a few models, the relevant ones are: 

  • event
  • venue
  • hall
  • stand

This module is to manage stands in tradeshows, so an event can have a lot of stands, but only one venue, and a venue can have many halls and each hall can have many stands. 

At the moment it works, I am using Many2one fields to link everything up and it works. However, when I create a stand, I want to filter the options of the hall where the stand will be, to display only the available halls of the venue where the parent event is happening. 

I have been trying to accomplish that filter by using this in the stand model:

  ​event_id = fields.Many2one('dev.event', string='Event')
hall_id = fields.Many2one('dev.hall', string='Hall',
​ ​ ​ ​ ​ ​ ​domain="[('venue_id','=','event_id.venue_id')]")

Although the code doesnt throw an error, it also doesnt show any results.


I also tried taking the aproach of using a function for the domain... but that fell beyond my current experience, so I couldnt make it work.


Any help will be greatly appreciated.



1
Avatar
Vazgeç
Avatar
IRIG Events
Üretici En İyi Yanıt

Hello


Mily Shajan


Thank you very much for the links. I followed the video, but when I got to download the web_domain_field module, it says it is deprecated, therefore I will leave it as a last resort.


Cybrosys


Thank you for the snippet. unfortuanately for some reason the domain does not get applied on return. I added a sneaky print() statement to verify that the function was firing and it is, but the domain remains unchanged in the field. 


Also, the isue of using the on_change hook is that it will only fire when the field is actually changed, so when I edit the record without changing the event it will display the unfiltered options. I have figured that if I create another field to display the name of the venue from a computed field, the function will fire when event is modified and also when the record is loaded. However, although the function does fire, the domain still doesnt get applied on return. Could it have some sort of typo or something?


@api.depends('event_id')

def compute_hall_ids(self):

        domain = []

        for rec in self:

            print(f'The venue Id of the event {rec.event_id.name} is: {rec.event_id.venue_id.id}')

            rec.venue_name = rec.event_id.venue_id.name

            domain = [('venue_id.id', '=', rec.event_id.venue_id.id)]

        print(domain)

        return {'domain': {'hall_id': domain}}


The printout I get for the domain is  [('venue_id', '=', 7)] as an example



cheers!


FINAL SOLUTION:

After reading the documentation more in depth, I found out that the @api.onchange and @api.depends decorators, will not fire the return statement, so that is why it wasnt being applied. 

Using the web_domain_field module did the trick for me. Even on V17. 

Cheers!



1
Avatar
Vazgeç
Nicolás

Hi!
I am dealing with the same issue, working with odoo 17.

So to summarize, the only way you could solve it was by intslaling the Web Domain Field module? (https://apps.odoo.com/apps/modules/12.0/web_domain_field)

Thank you,
Nicolás

Avatar
Cybrosys Techno Solutions Pvt.Ltd
En İyi Yanıt

Hi,

You can solve the issue by applying the domain dynamically.

    


@api.onchange('event_id')

def _onchange_event_id(self):

   if self.event_id:

       domain = [('venue_id', '=', self.event_id.venue_id.id)]

   else:

       domain = []

   return {'domain': {'hall_id': domain}}


You can also refer to How to Apply Dynamic Domain for Relational Fields in 


Hope it helps

0
Avatar
Vazgeç
Avatar
Mily Shajan
En İyi Yanıt

Hi 

Create a dynamic domain for the field. Check this reference to set a dynamic domain for the field

Dynamic Domain for a field

Domain for Relational Fields in Odoo


Regards

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
Connecting a Namecheap domain with the Odoo app hosted on an AWS EC2 instance
domain ec2 v17
Avatar
Avatar
2
Şub 24
2821
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Avatar
Avatar
1
Eki 25
1211
How to add a new Many2one field in res.config.settings? Çözüldü
v17
Avatar
Avatar
Avatar
Avatar
4
Eki 25
3514
Add field to ALL models in Odoo
v17
Avatar
Avatar
Avatar
2
Eyl 25
2220
How to disable Email notification - You have been assigned to Çözüldü
v17
Avatar
Avatar
Avatar
Avatar
4
Eyl 25
7551
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