Odoo Help


how to make a loop without repetition in odoo

Vale Trood
on 7/10/15, 11:24 AM 619 views

Hi !!!!

I have a field named "project".

Now, i want to make a loop on project but without any repetition.

help please.

thanks a lot

can you explain what you want?

Solanki Shamji
on 7/10/15, 11:40 AM

You want to make a loop with no repetition ? ...

on 7/10/15, 11:43 AM

Hi Drees, Please explain well couldn't understand from question what you need.

Anil R. Kesariya
on 7/10/15, 1:14 PM


From what I understand you need a foreach loop to loop and print out something once for each project in projects. For this you will need to use t-foreach statement to accomplish what you need.
Here's an example of a similar kind of t-foreach loop in use:


Look at lines #9-11 and you'll see t-foreach="product.images" t-as="i" in the tag. From my limited understanding of how this works you'll need to use the model (in this case t-foreach=" product.images") that you're trying to print from, and then providing a looping variable in this case t-as="i". This looping variable should then be used on the field you want to print out in that model, in this case you can see the statement inside the tag on line #10:
t-field="i.image" class="img-responsive" t-field-options="{"widget": "image", "class": "img-responsive"}"

Forget the t-field-options statement for a second and just focus on the t-field attribute. You can see the looping variable ibeing used to loop/print out the field image. Essentially what the above statement is saying is foreach image field in the model product.images for the product page we are using this loop on (ie. within the scope of the product_id) this look will print out the image field once per image.

This may be a terrible explanation of the concept, and I welcome any corrections on my explanation, however if you have any questions please post in the comments below.

My recommendation would be to check out the official documentation on this here:

Luke Branch
on 7/10/15, 10:50 PM

It was something new :) Loop with no loop ;) Paradox.

Dr Obx
on 7/15/15, 6:01 AM

Vale Trood

--Vale Trood--

| 5 2 7
Tunis, France
--Vale Trood--

Vale Trood
On 7/15/15, 5:30 AM

I have had an sql constraint and its okay. Everything works fine ;)

_sql_constraints = [

('project_id_unique', 'UNIQUE(project_id,client_id)',

'Each client must have a unique project'),


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/10/15, 11:24 AM
Seen: 619 times
Last updated: 7/15/15, 6:01 AM