Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • E-learning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Sociale media-marketing
    • E-mailmarketing
    • Sms-marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Artificiële Intelligentie
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelwinkel
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Horeca & Hospitality
    • Bar en café
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van mede-eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brouwerij
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Diensten
    • Klusjesman
    • IT-hardware & ondersteuning
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Alle bedrijfstakken bekijken
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijsprogramma
    • Scale Up! Business Game
    • Odoo bezoeken
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Partner worden
    • Diensten voor partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

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

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
treeviewxmlinvisiblecontexthide columnodoo 19
3 Antwoorden
603 Weergaven
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
Annuleer
Codesphere Tech

Hello
Have you tried to pass the context from action?

Avatar
Zehntech Technologies Inc.
Beste antwoord

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
Annuleer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste antwoord

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
Annuleer
Avatar
Rohit Dhiman
Beste antwoord

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
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How to put a domain on context XML ? Odoo 8 Opgelost
xml context
Avatar
Avatar
Avatar
2
mrt. 19
14625
How can I create treeview inside a treeview
treeview xml
Avatar
0
jun. 15
5322
Show history sale by partner by product
treeview xml
Avatar
0
mrt. 15
5064
Always invisible fields on V18 Opgelost
xml invisible V18
Avatar
Avatar
1
jun. 25
7672
Hide menuitem based on company ID Opgelost
xml invisible multicompany
Avatar
Avatar
Avatar
Avatar
3
aug. 24
9341
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Partner worden
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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