İç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
    • Yapay Zeka
    • 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
Toplulukla etkileşime geçmek için kayıtlı olmanız gerekir.
Tüm Gönderiler İnsanlar Rozetler
Etiketler (Tümünü göster)
odoo accounting v14 pos v15
Bu forum hakkında
Toplulukla etkileşime geçmek için kayıtlı olmanız gerekir.
Tüm Gönderiler İnsanlar Rozetler
Etiketler (Tümünü göster)
odoo accounting v14 pos v15
Bu forum hakkında
Yardım

Odoo 19 - How to dynamically hide a list view column (column_invisible) based on a parent form boolean field?

Abone Ol

Bu gönderide etkinlik olduğunda bildirim alın

Bu soru işaretlendi
treeviewxmlinvisiblecontexthide columnodoo 19
3 Cevaplar
625 Görünümler
Avatar
Miguel Tamayo

Hi everyone,

I'm struggling to dynamically hide/show columns in a list view (tree) in Odoo 19 based on a boolean flag set in the parent event form.

My Goal:

I have a custom module that inherits from event.event and event.registration.

  • If the event has is_internal_training = True, I want to show the employee_id and employee_number columns in the attendees registration list view.

  • If it is False, these columns should be completely hidden (column_invisible).

What works:

In the Form View of event.registration, using invisible="not is_internal_training" works flawlessly.

The Problem:

In the List View (tree), I cannot find the correct syntax for column_invisible to achieve this without breaking the framework.

  • If I try using parent.is_internal_training, OWL crashes with Name 'parent' is not defined when opening the list view independently (e.g., via the smart button or action menus).

  • If I try reading from the context using standard evaluation, the columns don't hide or I run into circular ParseError on the backend vs EvalError on the client.

My Code Setup:

1. Models (event_event.py):

from odoo import fields, models

classEventEvent(models.Model):
    _inherit = 'event.event'

    is_internal_training = fields.Boolean(string="Internal Training", default=False)

2. Models (event_registration.py):

from odoo import fields, models

classEventRegistration(models.Model):
    _inherit = 'event.registration'

    employee_id = fields.Many2one('hr.employee', string="Employee")
    employee_number = fields.Integer(related='employee_id.employee_number', string='Employee Number', store=True, readonly=True)
    
    # Related field to expose the setting to the tree view
    is_internal_training = fields.Boolean(
        related='event_id.is_internal_training',
        string='Is Internal Training',
        readonly=True,
        store=True
    )


3. Main Event Form View (event_event_views.xml):

<xpath expr="//field[@name='tag_ids']"position="after">	​	​<fieldname="is_internal_training"string="Internal Training"/>
</xpath>

4. Target Inherited Views (event_registration_views.xml):

<recordid="view_event_registration_form_inherit_custom"model="ir.ui.view"><fieldname="name">event.registration.form.inherit.custom.website.event</field><fieldname="model">event.registration</field><fieldname="inherit_id"ref="event.view_event_registration_form"/><fieldname="arch"type="xml"><xpathexpr="//field[@name='name']"position="before"><fieldname="employee_id"placeholder="Search employee..."invisible="not is_internal_training" /><fieldname="employee_number"invisible="not is_internal_training" /></xpath></field></record><recordid="view_event_registration_tree_inherit_custom"model="ir.ui.view"><fieldname="name">event.registration.tree.inherit.custom.website.event</field><fieldname="model">event.registration</field><fieldname="inherit_id"ref="event.view_event_registration_tree"/><fieldname="arch"type="xml"><xpathexpr="//field[@name='name']"position="before"><fieldname="employee_number"optional="show"column_invisible="context.get('is_internal_training', False)"/><fieldname="employee_id"optional="show"column_invisible="context.get('is_internal_training', False)"/></xpath></field></record>

Since the attendees list view can be loaded inside the form but also globally (via smart buttons), what is the correct Odoo 19 way to dynamically evaluate column_invisible for this exact scenario using the context or the related field?

Thanks in advance!

0
Avatar
Vazgeç
Codesphere Tech

Hello
Have you tried to pass the context from action?

George

Good question. I’ve run into similar situations where behavior in tree views doesn’t always react as expected to values from the parent form. Interested to see what approaches others are using in Odoo 19 for this kind of requirement.

Avatar
Zehntech Technologies Inc.
En İyi Yanıt

Hello Miguel,

What you're trying to achieve is a common limitation of tree views in Odoo.

column_invisible is evaluated at the view level, not per record, so it cannot reliably react to a related field value such as is_internal_training when the list is opened independently or contains records from multiple events.

Using parent.is_internal_training only works when a parent record exists in the view context, which is why it fails when the tree view is accessed directly.

For Odoo 19, the recommended approach is typically to:

  • Pass a dedicated context value from the Event form/action and use that context in column_invisible, or
  • Use separate actions/views for internal-training registrations versus standard registrations.

A related field on event.registration can control row-level visibility (invisible), but not dynamic column visibility (column_invisible) across all entry points.

Hope this works for you! If you need any help implementing this or want a more optimized approach, feel free to reach out for further discussion.

Regards,

Zehntech Technologies Inc.

santosh.sekwadia@zehntech.com

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

Hi,

In Odoo 18 and above, <tree> is replaced by <list>, so make sure your inherited view uses <list> tag. The correct way to dynamically hide columns via column_invisible based on a parent form boolean is to pass the flag through context and read it with context.get() this avoids the parent. crash when the view is opened standalone. In your event_event_views.xml, inject the flag from the parent form's stat button or embedded field:

<button name="%(event.event_registration_action_main)d" type="action"
        context="{'is_internal_training': is_internal_training}" />

Then in your registration list view use context.get() with a safe fallback:

<record id="view_event_registration_list_inherit_custom" model="ir.ui.view">
    <field name="name">event.registration.list.inherit.custom</field>
    <field name="model">event.registration</field>
    <field name="inherit_id" ref="event.view_event_registration_tree"/>
    <field name="arch" type="xml">
        <xpath expr="//list//field[@name='name']" position="before">
            <field name="employee_id"
                   optional="show"
                   column_invisible="not context.get('is_internal_training', False)"/>
            <field name="employee_number"
                   optional="show"
                   column_invisible="not context.get('is_internal_training', False)"/>
        </xpath>
    </field>
</record>

When opened inside the event form, the context carries is_internal_training: True and the columns appear; when opened standalone via a smart button or menu without the key, context.get() safely defaults to False and the columns stay hidden with no OWL crash. Your is_internal_training related field on event.registration should still be kept for the form view invisible= attribute to keep working independently.


Hope it helps

0
Avatar
Vazgeç
Avatar
Rohit Dhiman
En İyi Yanıt

if you are using odoo19 use list instead of tree wherever you use tree change it to list 
then i hope it should be working as expected

0
Avatar
Vazgeç
Tartışma hoşunuza mı gidiyor? Sadece okumakla kalmayın, katılın!

Özel özelliklerden yararlanmak ve harika topluluğumuzla etkileşime geçmek için bugün bir hesap oluşturun!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
How to put a domain on context XML ? Odoo 8 Çözüldü
xml context
Avatar
Avatar
Avatar
2
Mar 19
14646
How can I create treeview inside a treeview
treeview xml
Avatar
0
Haz 15
5333
Show history sale by partner by product
treeview xml
Avatar
0
Mar 15
5069
Always invisible fields on V18 Çözüldü
xml invisible V18
Avatar
Avatar
1
Haz 25
7682
Hide menuitem based on company ID Çözüldü
xml invisible multicompany
Avatar
Avatar
Avatar
Avatar
3
Ağu 24
9347
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 Svenska ภาษาไทย 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