Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Food & Hospitality
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Guest House
    • Distribuidor de bebidas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consulting
    • Accounting Firm
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Trades
    • Handyman
    • Hardware y asistencia informática
    • Solar Energy Systems
    • Zapatero
    • Servicios de limpieza
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

change tree color with field function

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
treecolors
2 Respuestas
12468 Vistas
Avatar
Sebastian Schadock

Hello,

I want to change the tree list item colors with my own field functions.

purchase_view.xml:

    <record model="ir.ui.view" id="view_purchase_color_open_orders">
    <field name="name">purchase_order_tree_color_open_orders</field>
    <field name="model">purchase.order</field>
    <field name="inherit_id" ref="purchase.purchase_order_tree"/>
    <field name="arch" type="xml">            
        <xpath expr="//tree[@string='Purchase Order']" position="inside">
            <field name="is_green" invisible="1"/>
            <field name="is_orange" invisible="1"/>
            <field name="is_red" invisible="1"/>
        </xpath>
        <xpath expr="//tree[@string='Purchase Order']" position="attributes">
            <attribute name="colors">                    
                green:is_green=='True';
                orange:is_orange=='True';
                red:is_red=='True'
            </attribute>
        </xpath>
    </field>
</record>

is_green, is_orange and is_red are my functions and this is the definition:

    _columns = {
             'is_green': fields.function(_is_green, type = 'boolean'),
             'is_orange': fields.function(_is_orange, type = 'boolean'),
             'is_red': fields.function(_is_red, type = 'boolean'),
               }

The functions works without any problem, but the view color all items green (always the first color).

I also tryed:

            <attribute name="colors">                    
                green:('is_green', '=', 'True');
                orange:('is_orange', '=', 'True');
                red:('is_red', '=', 'True')
            </attribute>

with the same result.

Is this the right way, or is there another opportunity to solve the problem?

Regards,

Sebastian

2
Avatar
Descartar
Avatar
Sebastian Schadock
Autor Mejor respuesta

I find the solution:

        <xpath expr="//tree[@string='Purchase Order']" position="attributes">
            <attribute name="colors">
                green:is_green==True;
                orange:is_orange==True;
                red:is_red==True
            </attribute>
        </xpath>

U have to compare boolean values without ' '.

3
Avatar
Descartar
Avatar
Francesco OpenCode
Mejor respuesta

Try to set the function storable.

_columns = {
         'is_green': fields.function(_is_green, type = 'boolean', store=True),
         'is_orange': fields.function(_is_orange, type = 'boolean', store=True),
         'is_red': fields.function(_is_red, type = 'boolean', store=True),
           }
1
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo 11.0 custom colors on tree views Resuelto
tree colors odoo11.0
Avatar
Avatar
Avatar
2
jul 21
18357
tree colors in a view contains a statusbar ?? Resuelto
tree colors tree_view
Avatar
Avatar
1
mar 15
7013
coloring a sale order line
colors
Avatar
Avatar
Avatar
6
ene 19
10106
Is it possible to change color of a field?
colors
Avatar
Avatar
Avatar
Avatar
3
abr 17
11279
colors in tree view always return true
colors
Avatar
1
mar 15
5361
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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