Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
4075 Представления

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>

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Автор Лучший ответ

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

Аватар
Отменить

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.

Автор

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.

Автор

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 Ответы Просмотры Активность
1
февр. 21
2144
0
авг. 24
1224
1
дек. 20
6146
0
авг. 15
3169
1
мая 25
492