Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
5 Odpowiedzi
3698 Widoki

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

Awatar
Odrzuć

can you explain what you want?

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

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

@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

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

Autor Najlepsza odpowiedź

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'),

]

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
mar 25
1261
0
sty 25
3300
1
sie 23
14609
change password Rozwiązane
1
sie 23
13253
1
lip 23
10256