Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

statusbar refuses to be colored

Subscribe

Get notified when there's activity on this post

This question has been flagged
stagesstatestatusbar
3 Replies
16869 Views
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
Discard
Avatar
Jordan Vrtanoski
Best Answer

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
Discard
Avatar
ZEeineb
Best Answer

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
Discard
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
Best Answer

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
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
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
Jan 25
4910
Automaticaly creating the stages when module will be install Solved
stages enterprise statusbar v14
Avatar
Avatar
1
Jan 24
2112
state selection field doesn't accept new default value (odoo 12) Solved
selection state statusbar odooV12
Avatar
Avatar
Avatar
4
May 19
13242
State statusbar in form view alligns left
xml state statusbar helpdesk
Avatar
Avatar
1
Mar 15
7893
[SOLVED] How to modify "State" when create "Sale Order" in module "Sale"
state statusbar sale.order sale.sale
Avatar
Avatar
2
Mar 15
7196
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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