Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profit organisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How to use varibales in <t t-foreach tag

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
xmlinheritanceqweb
3 Antwoorden
28351 Weergaven
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
Annuleer
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
Auteur

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

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
t-att-href url get error Opgelost
xml qweb
Avatar
Avatar
2
apr. 23
9682
How to modify a qweb template? Opgelost
inheritance qweb
Avatar
Avatar
2
dec. 22
23941
Get data from python to qweb view
xml qweb
Avatar
3
sep. 20
5340
How do you iterate fields in qweb reports?
xml qweb
Avatar
Avatar
Avatar
2
apr. 20
7397
Qweb Inheritance Opgelost
inheritance qweb
Avatar
Avatar
Avatar
3
nov. 19
8755
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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