OpenERP – Custom colors and styles for form fields

Some of our customers asked for highlighting particular fields in particular views. At the moment this is not possible in standard OpenERP.

We created a new OpenERP module that will allow you to specify different colors or CSS class per field in views definition.

Three new attributes will be available on the field element of a view:

  • bgcolor: for setting the background color;
  • fgcolor: for setting the foreground color (basically the text);
  • ccsclass: for setting a custom CSS class to be applied on the field.

bg/fgcolor are very useful for people that only want to change some field color without having to deal with CSS, while cssclass comes in handy  for assigning the same styles to a group of fields.

How to use it

  1. download it from launchpad or apps
  2. you must apply a simple patch to this server’s file `server/openerp/addons/base/rng/view.rng`. Just use the patch provided by this module (see server-view.rng.patch in the root of the package). This file declares the allowed attributes for any XML element (like <record /> <field /> etc.) so if you do not patch it you will get an error on form rendering;
  3. install it as any other module;
  4. customize a view. You can for instance modify a field declaration in any form view like this:
<field name="name" bgcolor="green" fgcolor="yellow" cssclass="myCssClass" />

And you are done! As usual any help / test / bug reporting is much appreciated. If you need to file a bug, please, do it on lp bug tracker.

Facebook Twitter Linkedin Digg Delicious Reddit Stumbleupon Tumblr Posterous Email Snailmail

Written by on Monday, September 3rd, 2012

  • anoop

    Great work.. thanks for this article

  • Maulik vadhar

    Really great 🙂

  • almodhesh

    thanks alot

  • http://twitter.com/TimothySolomon Timothy Solomon

    Nice tweaks for openerp! I presume you could also use “html style” tags in your view to set the colour? bit neater this way though..
    (would be nice to have a “style” attribute where you could put in any custom css)

    • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

      This should be the purpose of ‘cssclass’ attribute

  • tom

    doesn’t work on 6.1.1 ?

    • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

      It should

  • Anup

    Ya, it’s good to show the for view with colors…:)

  • ricardo

    Very nice idea..

    I was searching the web for a openerp module that could add a clock/timer when a new project task work is open… for v7..

    Do you have any ideas for this?

    Thx

  • Aryé Halioua

    Thanks for sharing.
    Could you please let me know can I use ‘cssclass’ to pick a color/style for the header banner of a form? (class=”oe-view-manager-header”).
    Regards.

  • VijayaKumar

    I am new to openerp. I would like to change theme customization (html/css) for helpdesk module in below menu path.

    Sales => Configuration = > Helpdesk => Categories

    where i need to change the css for above help desk module.

  • Mahdi

    Hello , thanks for the helpful module , but it dosn’t work . Its blocked when i install it 🙁

    • http://it.linkedin.com/in/elbati/ Lorenzo Battistini

      Hello. The module works with OpenERP 6.1 only

  • http://luengocabanillas.es Alberto Luengo Cabanillas

    Hi and congrats for your work!.
    Could you please provide an example with ‘cssclass’ attribute?.
    I don’t get to make it work with my module custom css.
    Thanks in advance!