0
votes

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.

2

2 Answers

1
votes

Can't test this at the moment, but here's an idea that might work:

Make two <tr> for each iteration (1 for each style). In one of them, check if the index is even or removeParentNode('tr'), in the other, check if the index is odd or removeParentNode('tr'). This way only one or the other table row will display on each iteration, but not both.

Example (untested):

<tr style="style1">[[ (index%2 == 0 and display.content) or removeParentNode('tr')]]</tr>
<tr style="style2">[[ (index%2 != 0 and display.content) or removeParentNode('tr')]]</tr>
1
votes

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'}) ]]