Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

repeatin error on empty list

By
N
on 5/17/13, 11:15 AM 1,800 views

[[ 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

1

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 5/17/13, 11:44 AM

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.

0

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 5/17/13, 11:58 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 5/17/13, 11:15 AM
Seen: 1800 times
Last updated: 3/16/15, 8:10 AM