Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
6371 Ansichten

[[ repeatIn([line for line in o.order_line if (line.is_option)],'line') ]]

I want to loop on all the lines of an order line wich are options lines (i put a boolean to handle that). The problem is when i don't have option lines in my sale order, i have the error : (<type 'exceptions.assertionerror'="">, AssertionError(), <traceback object="" at="" 0x09064508="">)

Any ideas to handle that problem ? Thanks

Avatar
Verwerfen
Beste Antwort

I don't have any idea how to skip loop iteration when given condition satisfy. But there is an alternate, you can remove content when your condition satisfy.

For example I want to remove row from table when line.is_option is True:

[[ repeatIn([line for line in o.order_line 'line') ]]
<tr><td>
    <para style="terp_default_9">Desc. : [[ (line.name and not line.is_option) or removeParentNode('tr') ]]</para>
</td></tr>

Hope this will help you.

Avatar
Verwerfen
Beste Antwort

You can use python boolean operator to check if a list is full or empty:

[[ repeatIn([line for line in (o.order_line or []) if (line.is_option)],'line') ]]

The code

(o.order_line or [])

return o.order_line if this one is full or an empty list that will not be looped.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
März 15
5057
3
März 15
5448
2
März 15
6034
1
Jan. 24
4255
2
März 22
20340