Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Foreach in qweb report xml Odoo 8

Odoberať

Get notified when there's activity on this post

This question has been flagged
pythonxmlforeachodooV8
4 Replies
12928 Zobrazenia
Avatar
Fadhel J Muhammad

I want to show data like this:

No | Code | Brand | Cost 
------------------------
 1 |  201 |       |
------------------------
   |      |   A   | 200
   |      |   B   | 350
------------------------
 2 |  202 |       |
------------------------
   |      |   C   | 100
   |      |   D   | 110


This is my code in py and xml:

Code in py:

report=self.env['report']
document=self._get_pos_report_one(data)
docss=self._get_pos_report_two(data)
ctx=self._context.copy()
object=self.env['report.wizard'].browse([ctx['active_id']])
data={'o':object,
      'docs':document,
      'docss':docss}
return report.render('report.report_sales', data)

Code in xml:

<tr t-foreach="docs" t-as="row" class="line_bottom line_top pb_font_10 text_bold">
    <td class="pb_text_center line_left">                                   
        <t t-set="num" t-value="num + 1"/>
        <t t-esc="num"/>
    </td>
    <td class="pb_text_left line_left">
        <span t-esc="row['code']"/>
    </td>

    <tr t-foreach="docss" t-as="row_detail" class="pb_font_10">
        <td class="pb_text_center line_left">
        </td>
        <td class="pb_text_left line_left">
        </td>
        <td class="pb_text_left line_left">
            <span t-esc="row_detail['brand']"/>
        </td>
        <td class="pb_text_left line_left">
            <span t-esc="row_detail['cost']"/>
        </td>
    </tr>
</tr>

This is current result with my code (py and xml):

No | Code | Brand | Cost 
------------------------
 1 |  201 |       |
------------------------
   |      |   A   | 200
   |      |   B   | 350
   |      |   C   | 100
   |      |   D   | 110
------------------------
 2 |  202 |       |
------------------------
   |      |   A   | 200
   |      |   B   | 350
   |      |   C   | 100
   |      |   D   | 110

I've tried with code - docss(row['code']) - docss.code and many more.

Hope someone helps me. Thankyou!

0
Avatar
Zrušiť
Mohammed Amal N

Hi, pass a dictionary from your parser to get data in the required format or give a t-if condition for new lines.

Fadhel J Muhammad
Autor

Hi, i've solved the problem with t-if. Thanks!

Sehrish

How loops work in Qweb: https://learnopenerp.blogspot.com/2020/08/create-custom-report-in-odoo-using-qweb.html

Avatar
Fadhel J Muhammad
Autor Best Answer

I've solved the problem:

<tr t-foreach="docs" t-as="row" class="line_bottom line_top pb_font_10 text_bold">
<td class="pb_text_center line_left">                                   
    <t t-set="num" t-value="num + 1"/>
    <t t-esc="num"/>
</td>
<td class="pb_text_left line_left">
    <span t-esc="row['code']"/>
</td>

<tr t-foreach="docss" t-as="row_detail" class="pb_font_10">
  <t t-if="row['code']==row_detail['code']">
    <td class="pb_text_center line_left">
    </td>
    <td class="pb_text_left line_left">
    </td>
    <td class="pb_text_left line_left">
        <span t-esc="row_detail['brand']"/>
    </td>
    <td class="pb_text_left line_left">
        <span t-esc="row_detail['cost']"/>
    </td>
  </t>
</tr>
0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to add restriction to Users in Odoo
python xml odooV8
Avatar
Avatar
1
nov 22
4115
Document type: account.analytic.account, Operation: read
python xml odooV8
Avatar
Avatar
1
feb 21
8288
How to know menu parent id? Solved
python xml odooV8
Avatar
Avatar
1
jan 16
7721
How to hyperlink sale order confirmed in email template ? Solved
python xml odoo odooV8
Avatar
Avatar
1
nov 21
12368
Call Python function from JavaScript Solved
javascript python xml odooV8
Avatar
Avatar
Avatar
Avatar
6
jan 19
27254
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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