Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
712 Представления

<t t-foreach="doc.x_studio_many2many_field_6jb_1impe105v.sorted(key=lambda x: x.x_studio_ue_de_lannee.x_studio_many2one_field_4zxcY.x_studio_nom_de_lue)" t-as="line">


<tr style="color:none">


<td id="ue">

<span style="text-align:left;" t-field="line.x_studio_ue_de_lannee.x_studio_many2one_field_4zxcY.x_studio_nom_de_lue" class="o_small-fs"/>


</td>


<td id="ecue">


<span t-field="line.x_studio_ecue_de_lannee_1.x_studio_many2one_field_3n1X8.x_studio_nom_de_lecue" class="o_small-fs"/>


</td>

<td id="cours_theoriques">

<span t-field="line.x_studio_moy_cm_final" class="o_small-fs"/>

</td>


<td id="cours_pratiques">


<span t-field="line.x_studio_moy_tped_final" class="o_small-fs"/>


</td>


<td id="cours_travaux_personnels">


<span t-field="line.x_studio_moy_tpe_final" class="o_small-fs"/>


</td>


<td id="ecue">


<span t-field="line.x_studio_observations" class="o_small-fs"/>


</td>



</tr>


</t>




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

Hii,

  1. Group the lines by the M2O field.
  2. For each group, print the grouped value once, with rowspan = len(group).
  3. Then iterate the group items to fill the rest of the row.

Updated QWeb code with dynamic rowspan:
<t t-set="grouped_lines" t-value="{}"/>

<t t-foreach="doc.x_studio_many2many_field_6jb_1impe105v" t-as="line">

    <t t-set="ue_name" t-value="line.x_studio_ue_de_lannee.x_studio_many2one_field_4zxcY.x_studio_nom_de_lue"/>

    <t t-set="grouped_lines[ue_name]" t-value="grouped_lines.get(ue_name, []) + [line]"/>

</t>


<t t-foreach="grouped_lines.items()" t-as="item">

    <t t-set="ue" t-value="item[0]"/>

    <t t-set="lines" t-value="item[1]"/>


    <t t-foreach="lines" t-as="line" t-set="idx" t-value="loop.index0">

        <tr>

            <!-- Only show the UE cell on the first row of the group -->

            <t t-if="idx == 0">

                <td rowspan="<t t-esc='len(lines)'/>">

                    <span t-esc="ue" class="o_small-fs"/>

                </td>

            </t>

            

            <!-- ECUE and other columns -->

            <td>

                <span t-field="line.x_studio_ecue_de_lannee_1.x_studio_many2one_field_3n1X8.x_studio_nom_de_lecue" class="o_small-fs"/>

            </td>

            <td>

                <span t-field="line.x_studio_moy_cm_final" class="o_small-fs"/>

            </td>

            <td>

                <span t-field="line.x_studio_moy_tped_final" class="o_small-fs"/>

            </td>

            <td>

                <span t-field="line.x_studio_moy_tpe_final" class="o_small-fs"/>

            </td>

            <td>

                <span t-field="line.x_studio_observations" class="o_small-fs"/>

            </td>

        </tr>

    </t>

</t>

  • grouped_lines is a dictionary { ue_name: [lines...] }
  • For each UE group:
    • Print <td rowspan=X> once, in the first row.
    • The remaining lines print as normal rows without that first column.
Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
июн. 25
6310
1
июл. 25
1964
1
мая 25
2052
1
апр. 25
2484
1
февр. 25
1757