Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Verkauf
    • CRM
    • Verkauf
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Künstliche Intelligenz
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preise
  • Hilfe
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

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

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
treeviewxmlinvisiblecontexthide columnodoo 19
3 Antworten
640 Ansichten
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
Verwerfen
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.
Beste Antwort

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

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
Verwerfen
Avatar
Rohit Dhiman
Beste Antwort

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
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
How to put a domain on context XML ? Odoo 8 Gelöst
xml context
Avatar
Avatar
Avatar
2
März 19
14654
How can I create treeview inside a treeview
treeview xml
Avatar
0
Juni 15
5345
Show history sale by partner by product
treeview xml
Avatar
0
März 15
5076
Always invisible fields on V18 Gelöst
xml invisible V18
Avatar
Avatar
1
Juni 25
7714
Hide menuitem based on company ID Gelöst
xml invisible multicompany
Avatar
Avatar
Avatar
Avatar
3
Aug. 24
9366
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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