Skip to Content
Menu
This question has been flagged
2 Replies
3679 Views

Hi all !

I'll try to be as clear as possible.

I'm creating a web view so creating an xml file.

I have a table to show different size of same product.
But if there is more than 7 I want to create a new row to keep it clear on webpage.
So I have a conditional on the index_i variable (didn't still understood how to use $a_index)
when 7 is reached I want to add "</tr><tr>" to make a new row.
But when updating the module I have an error :"lxml.etree.XMLSyntaxError: expected '>' "

Here is my code :

<table border="1">
                                    <tr>
                                        <t t-set="attribute" t-value="toto.product_variant_ids"/>
                                        <t t-set="index_i" t-value="1"/>
                                        <t t-foreach="attribute" t-as="tutu">
                                            <p t-if="index_i==7">
                                                </tr><tr>             
                                            </p>
                                            <td>
                                                <p t-esc="tutu.display_name"/>
                                            </td>
                                            <t t-set="index_i" t-value="index_i+1"/>
                                         </t>
                                    </tr>
                                </table>


Any idea ?


Thanks a lot !

================  THE SOLUTION : ============

I changed this part of code :
                                            <p t-if="index_i==7">
                                                </tr><tr>             
                                            </p>

by :
                                            <t t-if="index_i==10 or index==5">
                                                <tr></tr>
                                            </t>

note the inversion of <tr></tr>

Avatar
Discard
Best Answer

Hello Hedge
May be issue is in </tr><tr> tag because you are closing tag which is not opened yet so update your code.

<table border="1">
                                    <tr>
                                        <t t-set="attribute" t-value="toto.product_variant_ids"/>
                                        <t t-set="index_i" t-value="1"/>
                                        <t t-foreach="attribute" t-as="tutu">
                                            <p t-if="index_i==7">
                                                <tr></tr>             
                                            </p>
                                            <td>
                                                <p t-esc="tutu.display_name"/>
                                            </td>
                                            <t t-set="index_i" t-value="index_i+1"/>
                                         </t>
                                    </tr>
                                </table>

Thanks

Avatar
Discard
Author Best Answer

Hi Husain !

Thanks to answer !

In fact the opening <tr> is in line 2.
So when the index rate 7 to create a new line, I close the first row and create a second in line 7.
then I open <td> whatever the index is !

Have a nice day

Avatar
Discard

You can not close </tr> tag like this if you want to close that opening <tr> then you must first close </P> and then </t> tag which is inner tag.

Author

Hi Husain !

Ha ok !? but If I do that my loop will stop ?

Simply you just need to open and close <tr></tr> inside loop.

Remove tr tag from starting.

Author

So the solution was in between ;-) :

I changed this part of code :

<p t-if="index_i==7">

</tr><tr>

</p>

by :

<t t-if="index_i==10 or index==5">

<tr></tr>

</t>

note the inversion of <tr></tr>

Related Posts Replies Views Activity
1
Feb 21
1714
0
Aug 24
468
1
Dec 20
5708
0
Aug 15
2779
0
Oct 24
118