Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Inteligência Artificial
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Gestão de Imóveis
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Agende uma Demonstração
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

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

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
treeviewxmlinvisiblecontexthide columnodoo 19
3 Respostas
634 Visualizações
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
Cancelar
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.
Melhor resposta

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
Cancelar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Melhor resposta

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
Cancelar
Avatar
Rohit Dhiman
Melhor resposta

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
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscrever-se
Publicações relacionadas Respostas Visualizações Atividade
How to put a domain on context XML ? Odoo 8 Resolvido
xml context
Avatar
Avatar
Avatar
2
mar. 19
14652
How can I create treeview inside a treeview
treeview xml
Avatar
0
jun. 15
5340
Show history sale by partner by product
treeview xml
Avatar
0
mar. 15
5073
Always invisible fields on V18 Resolvido
xml invisible V18
Avatar
Avatar
1
jun. 25
7705
Hide menuitem based on company ID Resolvido
xml invisible multicompany
Avatar
Avatar
Avatar
Avatar
3
ago. 24
9353
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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