Odoo Help


statusbar refuses to be colored

on 5/7/13, 11:03 AM 6,549 views

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:

    <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"}'/>

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?

Jordan Vrtanoski
On 11/12/13, 1:38 PM

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.

Aaron Neo
On 10/3/13, 1:03 PM

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 = {

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">
                    <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"}'/>

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

On 8/30/13, 7:21 AM

Hi Adrian,

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

 _defaults = {  
        'stage_id': 'draft',

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
on 10/2/13, 7:58 AM

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
on 10/2/13, 7:58 AM

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

on 10/3/13, 10:48 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 5/7/13, 11:03 AM
Seen: 6549 times
Last updated: 3/16/15, 8:10 AM