Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to use varibales in <t t-foreach tag

Odebírat

Get notified when there's activity on this post

This question has been flagged
xmlinheritanceqweb
3 Odpovědi
28353 Zobrazení
Avatar
Cyrus Waithaka

I am trying to add a slideshow to the product.template form view. In this, I want to show all images related to a product as a slideshow on the backend.

I have managed to create the product.image class and created the one2many relationship successfully as follows.


class product_product(osv.Model): _inherit = "product.template" _columns = { 'images': fields.one2many( 'product.images', 'product_id', 'Product Images' ) }

I however have a problem displaying the list of images using a <t-foreach tag. Here is the part of the view that I am adding to the product.product_template_form_view view.

 <div class="slider project-slider slider-for">
<t t-foreach="record.images" t-as="i"> 
<div><span t-field="i.image" class="img-responsive" t-field-options="{"widget": "image", "class": "img-responsive"}"/></div>
</t>
</div>

I suppose the line <t t-foreach="record.images" ...... is not fetching the current product object. How to I make it to iterate through the "images" field of the current record?

Here is the full xml file

        <record id="view_product_form_img" model="ir.ui.view">
<field name="name">product.product.images</field>
<field name="model">product.template</field>
<field name="priority">3</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<page string="Sales" position="after">
<!--<page string="Product Slider">
<field name="images" nolabel="1"/>
</page> -->
<!-- a copy of website_multi_image/product_images.xml-->
<page string="Product Images">
<field name="images" mode="kanban" context="{'default_name': name}">
<kanban>
<field name="name"/>
<field name="description"/>
<field name="image_alt"/>
<field name="image"/>
<templates>
<t t-name="kanban-box">
<div style="position: relative">
<div class="oe_module_vignette">
<a type="open">
<img t-att-src="kanban_image('res.partner', 'image', record.id.value, {'preview_image': 'image_small'})" class="oe_avatar oe_kanban_avatar_smallbox"/>
</a>
<div class="oe_module_desc">
<div class="oe_kanban_box_content oe_kanban_color_bglight oe_kanban_color_border">
<table class="oe_kanban_table">
<tr>
<td class="oe_kanban_title1" align="left" valign="middle">
<h4><a type="open"><field name="name"/></a></h4>
<i><div t-if="record.description.raw_value">
<field name="description"/></div></i>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
<!-- a copy of website_multi_image/website_product_image_carousel.xml to display the slider-->
<div class="container-fluid">
<style>
.slider-for {
min-height:50px;
background-color:grey;
}
.slider-nav {
min-height:20px;
}
</style>
<div class="row-fluid">
<p class="oe_grey">
<strong>Note:</strong> display the slideshow here now.
</p>
<div class="slider slider-for">
<t t-foreach="product.images" t-as="i">
<h2 t-esc="i.name"/>
<div><span t-field="i.image" class="img-responsive" t-field-options="{"widget": "image", "class": "img-responsive"}"/></div>
</t>
</div>
</div>
<div class="row-fluid">
<div class="slider slider-nav">
<t t-foreach="product.images" t-as="i">
<h2 t-esc="i.name"/>
<div><span t-field="i.image" class="img-responsive" t-field-options="{"widget": "image", "class": "img-responsive"}"/></div>
</t>
</div>
</div>
</div>
</page>
</page>
</field>
</record>

I realised the qweb tags is not being processed


0
Avatar
Zrušit
Luke Branch

@Cyrus,

I'd recommend taking a look at this project:

https://github.com/OdooCommunityWidgets/website_multi_image/tree/8.0/website_multi_image

Specifically this file:

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

Cyrus Waithaka
Autor

Hi Luke, thats the project I am using. I have edited the question to include my xml file in full. I realised the qweb tags in the view are not being processed.

Sehrish

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

Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
t-att-href url get error Vyřešeno
xml qweb
Avatar
Avatar
2
dub 23
9685
How to modify a qweb template? Vyřešeno
inheritance qweb
Avatar
Avatar
2
pro 22
23942
Get data from python to qweb view
xml qweb
Avatar
3
zář 20
5341
How do you iterate fields in qweb reports?
xml qweb
Avatar
Avatar
Avatar
2
dub 20
7397
Qweb Inheritance Vyřešeno
inheritance qweb
Avatar
Avatar
Avatar
3
lis 19
8757
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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