odooopenerp-7rml

Dynamic style on RML documents


What I need is to have every second row of a table to have a different background colour. I have successfully created my method that can be called from the rml document and returns the hex colour. What I need is a way on rml side to set the background-colour attribute of the tr tag to the return value of my method. How can this be done ? I have been using the official documentation and looking specifically at the chapter 11 Conditional formatting but I do not see anything. Essentially what I want to do it the following:

<tr style="background-colour: [[_get_colour(index)]];" />

_get_colour will return a string that will contain the hex value of a colour

Edit: As it turns out the docIf RML tags that are used for conditional formatting are not implemented in openerp v7 according to this and I have to resort to a different solution.


Solution

  • I found an example of that problem being solved in an rml in the system. I ended up resolving the issue with the following:

    <tr>[[ setTag('tr','tr',{'style': 'Move_Line_Contect_Assign_State_background' if picking.move_lines.index(move_lines) % 2 else 'Move_Line_Contect_Assign_State'}) ]]