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
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • 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

statusbar refuses to be colored

Suscribirse

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

Se marcó esta pregunta
stagesstatestatusbar
3 Respuestas
16872 Vistas
Avatar
Muszik Adrián

In my custom module i have this field:

'stage_id': fields.selection([
        ('draft', 'Draft'),
        ('final', 'Final'),
        ('modified', 'Modified'),
        ], 'Status',
        help="Contract Status", track_visibility='onchange'),

and in the XML view:

<header>
    <button name="action_final" attrs="{'invisible': [('stage_id', '!=', 'draft')]}" type="object" string="Final" class="oe_highlight"/>
    <button name="action_modified" attrs="{'invisible': [('stage_id', '!=', 'final')]}" type="object" string="Modified" class="oe_highlight"/>
    <field name="stage_id" widget="statusbar"  statusbar_visible="draft,final,modified"  statusbar_colors='{"draft":"red","final":"blue"}'/>
</header>

and yet my statusbar widget refuses to be colored on any stage. I am trying to use stage_id as states, thought.

or am i using states in a wrong way?

6
Avatar
Descartar
Avatar
Jordan Vrtanoski
Mejor respuesta

Check the following post: ../question/2154/how-to-add-a-new-value-to-a-selection-field-state-in-saleorder/

If you still have problem with the colour, check if the same field (in your case 'state') appears twice in the form. If this is the case, the widget "statusbar" won't display the colour properly.

5
Avatar
Descartar
Avatar
ZEeineb
Mejor respuesta

Hi Adrian,

Try to define a default value for your custom selection field on the python class. Here an example:

 _defaults = {  
        'stage_id': 'draft',
        }
1
Avatar
Descartar
Aaron Neo

Hi there, I have the same problem. The states just simply refuse to be colored. I have set _defaults for my state but it still does not get colored. Anything else that I am missing?

Aaron Neo

Hi there, I have the same problem. The states just simply refuse to be colored. I have set _defaults for my state but it still does not get colored. Anything else that I am missing?

ZEeineb

Hi Aaron Neo, could you post your code here please like Adrian?

Avatar
Aaron Neo
Mejor respuesta

Hi ZEeineb,

I attach my code here.

class Asset(osv.osv):
_name = "asset"
_description = "Asset (MRO of Assets)"
_inherit = "product.product"
_columns = {
        'deployed': fields.boolean('Deployed'),
        'asset_deploy_address': fields.one2many('asset_deploy_address', 'asset_id', 'Deploy Address'),
        'current_customer': fields.related('asset_deploy_address', 'address_id', 'customer_id', 'name', type='char', string='Customer'),
        'current_location': fields.related('asset_deploy_address', 'address_id', 'name', type='char', string='Location'),
        'current_address': fields.related('asset_deploy_address', 'address_id', 'address', type='char', string='Address'),
        'stage': fields.selection([
            ('new', 'Draft'),
            ('deploy', 'Deploy Asset'),
            ('complete', 'Completed'),              
            ],'Status', readonly=True, select=True, help='Workflow stages'),
        }
_defaults = {
        'deployed':False,
        'stage':'new',
        }

After much investigation, I found out that it is due to inheriting product.product model. Because product.product already has "state" fields, so specifying my own "state" field would add-on to it. However, states are still not being colored in the statusbar widget. I didn't have the energy and time to read into the source code of OpenERP base to find out the root cause.

In the end, my solution is to change my "state" field to "stage". Then in my view (XML) i used "attrs" attribute to hide buttons by detecting the value of "stage" field element. See code below.

<record model="ir.ui.view" id="asset_form_view">
        <field name="name">asset.form.view</field>
        <field name="model">asset</field>
        <field name="type">form</field>
        <field name="priority" eval="1"/>
        <field name="inherit_id" ref="product.product_normal_form_view"/>           
        <field name="arch" type="xml">
            <sheet position="before">
                <header>
                    <button name="specify_holding_wh" string="Specify holding warehouse" attrs="{'invisible':['|',('stage','=','deploy'),('stage','=','complete')]}"/>
                    <button name="specify_holding_wh_repeat" string="Specify holding warehouse" attrs="{'invisible':['|',('stage','=','new'),('stage','=','complete')]}"/>
                    <field name="stage" widget="statusbar" statusbar_visible="new,deploy,complete" statusbar_colors='{"new":"red","complete":"blue"}'/>
                </header>
            </sheet>

This workaround works pretty well. My "stage" statusbar widget now gets colored and buttons show and hide as desired. If you know how to solve the inherited "state" field problem, let tell me how. Thanks!

Regards, Aaron

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
How to change the order of status bar states in Odoo 18 after adding a new state, without override the field?
state statusbar Selection selectionfield
Avatar
1
ene 25
4912
Automaticaly creating the stages when module will be install Resuelto
stages enterprise statusbar v14
Avatar
Avatar
1
ene 24
2115
state selection field doesn't accept new default value (odoo 12) Resuelto
selection state statusbar odooV12
Avatar
Avatar
Avatar
4
may 19
13244
State statusbar in form view alligns left
xml state statusbar helpdesk
Avatar
Avatar
1
mar 15
7894
[SOLVED] How to modify "State" when create "Sale Order" in module "Sale"
state statusbar sale.order sale.sale
Avatar
Avatar
2
mar 15
7201
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