Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Referencing views from other pages

Subscriure's

Get notified when there's activity on this post

This question has been flagged
viewswebsite_builderwebsitev10
1 Respondre
3268 Vistes
Avatar
Nathan Hardwick

I am trying to understand how to reference/retrieve information from other views on the website i.e. retrieve forum posts from another page. I can see how the forum page retrieves and displays the post but I can't see whether it is possible to reference the forum posts on another page, simply copying the same xml leads to a 500 server error as it cannot reach the data.

If you don't understand what I mean I can provide examples or clarify further.

1
Avatar
Descartar
Avatar
Jérémy Kersten (jke)
Best Answer
<ul t-foreach="request.env['forum.post'].search([])" t-as='p'>
    <li><span t-field='p.name'/> </li>
</ul>


The forum is probably a bad example since 'a post' is not in a separated template...


But, just to give you an idea...


<ul t-foreach="request.env['forum.post'].search([('forum_id', '=', 1)])" t-as='p'>
<t t-call='website_forum.post_description_full'>
<t t-set='question' t-value='p'/>
<t t-set='user' t-value='request.env.user'/>
<t t-set='forum' t-value="request.env['forum.forum'].browse(1)"/>
<t t-set='reversed' t-value="lambda x: x"/>
<t t-set='searches' t-value="{}"/>
<t t-set='header' t-value="{}"/>
</t> 
</ul>

<t t-set='posts' t-value="request.env['forum.post'].search([('parent_id', '=' , False), ('forum_id', '=', 1)], order='create_date desc', limit=10)"/>
<h1> <t t-esc='len(posts)'/> lastest posts</h1>
<ul t-foreach="posts" t-as='p'>
    <li><span t-field='p.name' /></li>
</ul>

KR

1
Avatar
Descartar
Nathan Hardwick
Autor

This is exactly what I was after, thanks. I wanted to display some forum posts on another page just as a sort of taste of what is on the forums. I don't suppose you would know how to iterate through the forum posts and only display the first few?

Jérémy Kersten (jke)

Simply use the first example, and design yourself your box.

<t t-set='posts' t-value="request.env['forum.post'].search([('parent_id', '=' , False), ('forum_id', '=', 1)], order='create_date desc', limit=10)"/>

<h1> <t t-esc='len(posts)'/> lastest posts</h1>

<ul t-foreach="posts" t-as='p'>

<li><span t-field='p.name' /></li>

</ul>

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
Moving the "My Cart" button along the navbar
xpath website_builder website v10
Avatar
0
d’ag. 17
4907
How do i re-run the website builder to include the demo theme? Solved
website_builder website
Avatar
Avatar
Avatar
2
de set. 25
4633
Adding an HTML element to existing website template
website_builder website
Avatar
Avatar
1
de jul. 25
2085
How to add lottie animation to odoo site
website_builder website
Avatar
Avatar
Avatar
2
de juny 25
3477
Website - how to ask for email before allowing download of a pdf Solved
website_builder website
Avatar
Avatar
Avatar
3
d’abr. 25
3401
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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