Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How do you use variables in a Qweb loop?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
v8qwebreportloop
11 Răspunsuri
94512 Vizualizări
Imagine profil
Jeff Beidler

This page of the documentation describes variables that can be used in a t-foreach loop in Qweb, but doesn't provide any examples of how to access those variables.  I was thinking that I could use the $as_index variable to list line numbers on a sales order, but everything I have tried causes an error.  Can anyone provide an example of how to output the index?  Or, even better, the index + 1, since it starts at zero?

2
Imagine profil
Abandonează
Sehrish

look into: https://learnopenerp.blogspot.com/2020/08/create-custom-report-in-odoo-using-qweb.html

Imagine profil
Sajin Aziz
Cel mai bun răspuns

try this code inside table,

 <t t-set="i" t-value="1"/>

<tr t-foreach="o.order_line" t-as="l">
                        <td> <span t-esc="i"/> </td>

    <t t-set="i" t-value="i+1"/>
</tr>

18
Imagine profil
Abandonează
Jeff Beidler
Autor

That's what I came up with, too. Just wanted to know how to do it in the manner described in the "documentation".

iWesabe Technologies

+1

Imagine profil
Jeff Beidler
Autor Cel mai bun răspuns

I got the $as_index variable to work.  Here is an example:

<tr t-foreach="o.order_line" t-as="l">
                        <td>
                            <span t-esc="l_index + 1" />
. . .

The index is zero-based, hence the addition of 1.  Hope this helps.

7
Imagine profil
Abandonează
Imagine profil
Ajepe Babatope
Cel mai bun răspuns

This is pretty simple and straight forward.

When we define our loop like this:

<code>

<t t-foreach="people" t-as="person">

<tr>

<th scope="row"><span t-raw="person_index"/></th>

<td><span t-field="person.name"/></td>

<td><span t-field="person.age"/></td>

<td><span t-raw="person.weight"/></td>

</tr>

</t>

</code>

To get the current index/position of the person with the loop you can do person_index. i.e your variable_index or any other available variable withing the context of qweb loop.

3
Imagine profil
Abandonează
Imagine profil
Martin Pishpecki
Cel mai bun răspuns

I have tryed this:

<t t-set="i" t-value="1"/>
<tr t-foreach="o.order_line" t-as="l">
                        <td> <span t-esc="i"/> </td>
<t t-set="i" t-value="i+1"/>
</tr>

When the loop finishes, the ounter resets to 1. Does anyone kow a way to update a variable outside the loop? I would like to define a variable before the loop and set it to false. If I find what I am looking for inside the loop I would like to set the value of the variable to True. This var would later be used as a condition if a div is visible or not.

Any help is appreciated. Thx

0
Imagine profil
Abandonează
Imagine profil
Antony Lesuisse (al)
Cel mai bun răspuns

var_index is automatically defined

Check https://www.odoo.com/documentation/8.0/reference/qweb.html#loops

0
Imagine profil
Abandonează
Jeff Beidler
Autor

Yes, that is the page I linked in my question. What I was hoping for was an example of usage. Everything I tried resulted in an error.

Luke Branch

@Antony Lesuisse, Thanks for the link. I'm currently building a community module to add multiple product images for use in the website e-commerce pages here: https://github.com/OdooCommunityWidgets/website_multi_image unfortunately i've only just begun playing around with Odoo development and I have hit a brick wall trying to figure out how to create a t-foreach loop to output all images in the one2many in this module. Do you have any suggestions on how I could achieve this in 8.0?

OdooBot
https://www.odoo.com/documentation/8.0/reference/qweb.html

Use the doc Luke ! :)

On 12/04/2014 12:16 PM, Luke wrote:
> @Antony Lesuisse, Thanks for the link. I'm currently building a community
> module to add multiple product images for use in the website e-commerce pages
> here: https://github.com/OdooCommunityWidgets/website_multi_image
> unfortunately i've only just begun playing around with Odoo development and I
> have hit a brick wall trying to figure out how to create a t-foreach loop to
> output all images in the one2many in this module. Do you have any suggestions
> on how I could achieve this in 8.0?
>
> --
> Luke
> Sent by Odoo S.A.  using Odoo 
> about Forum Post False 
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Create QWeb reports from Odoo application
v8 qweb report
Imagine profil
0
dec. 15
5107
Edit the qweb template with a custom modul. Rezolvat
v8 qweb report
Imagine profil
Imagine profil
Imagine profil
3
mar. 15
18856
Transfer the sum of all order lines of one page to the next page.
v8 qweb report
Imagine profil
0
mar. 15
3946
Set report orientation Rezolvat
v8 qweb report
Imagine profil
Imagine profil
1
mar. 15
15056
Inherit Qweb Rezolvat
v8 qweb inherit report
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
feb. 24
49705
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now