Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Umělá inteligence
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
treeviewxmlinvisiblecontexthide columnodoo 19
3 Odpovědi
596 Zobrazení
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
Zrušit
Codesphere Tech

Hello
Have you tried to pass the context from action?

Avatar
Zehntech Technologies Inc.
Nejlepší odpověď

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
Zrušit
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Nejlepší odpověď

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
Zrušit
Avatar
Rohit Dhiman
Nejlepší odpověď

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
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to put a domain on context XML ? Odoo 8 Vyřešeno
xml context
Avatar
Avatar
Avatar
2
bře 19
14622
How can I create treeview inside a treeview
treeview xml
Avatar
0
čvn 15
5321
Show history sale by partner by product
treeview xml
Avatar
0
bře 15
5064
Always invisible fields on V18 Vyřešeno
xml invisible V18
Avatar
Avatar
1
čvn 25
7650
Hide menuitem based on company ID Vyřešeno
xml invisible multicompany
Avatar
Avatar
Avatar
Avatar
3
srp 24
9339
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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