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.

0

how to make a loop without repetition in odoo

By
Drees Far
on 7/10/15, 11:24 AM 334 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 ? ...

PY
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

@Drees,

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:

https://github.com/OdooCommunityWidgets/website_multi_image/blob/8.0/website_multi_image/views/website_product_image_carousel.xml

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:
https://www.odoo.com/documentation/8.0/reference/qweb.html#loops

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
0

Drees Far

--Drees Far--
1130
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
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'),

]

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

1 follower(s)

Stats

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