You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

  1. * In the tree view declaration, put ``options='{"bg_color": "red: customer==True"}`` attribute in the ``field`` tag::
  2. ...
  3. <field name="arch" type="xml">
  4. <tree string="View name">
  5. ...
  6. <field name="name" options='{"bg_color": "red: customer == True"}'/>
  7. ...
  8. </tree>
  9. </field>
  10. ...
  11. With this example, column which renders 'name' field will have its background colored in red.
  12. * In the tree view declaration, put ``options='{"fg_color": "white:customer == True"}'`` attribute in the ``field`` tag::
  13. ...
  14. <field name="arch" type="xml">
  15. <tree string="View name">
  16. ...
  17. <field name="name" options='{"fg_color": "white:customer == True"}'/>
  18. ...
  19. </tree>
  20. </field>
  21. ...
  22. With this example, column which renders 'name' field will have its text colored in white on a customer records.
  23. * In the tree view declaration, use ``options='"color_field": "my_color"'`` attribute in the ``tree`` tag::
  24. ...
  25. <field name="arch" type="xml">
  26. <tree string="View name" colors="color_field: my_color" >
  27. ...
  28. <field name="my_color" invisible="1"/>
  29. ...
  30. </tree>
  31. </field>
  32. ...
  33. * If you want to use more than one color, you can split the attributes using ';':
  34. .. code::
  35. options='{"fg_color": "red:red_color == True; green:green_color == True"}'
  36. Example:
  37. .. code:: xml
  38. ...
  39. <field name="arch" type="xml">
  40. <tree string="View name">
  41. ...
  42. <field name="name" options='{"fg_color": "red:red_color == True; green:green_color == True"}'/>
  43. ...
  44. </tree>
  45. </field>
  46. ...
  47. With this example, the content of the field named `my_color` will be used to
  48. populate the `my_color` CSS value. Use a function field to return whichever
  49. color you want depending on the other record values. Note that this
  50. overrides the rest of `colors` attributes, and that you need the tree
  51. to load your field in the first place by adding it as invisible field.
  52. **Note that you should always use single quotes for fields' ``options`` and wrap nested values in double quotes since ``options`` is a JSON object.**