Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Using qWeb templates in custom website theme

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
website
2 Risposte
3293 Visualizzazioni
Avatar
Luis H. Porras

Hi everyone, I'm trying to develop a custom theme for my odoo (v13) website but I'm struggling to create templates using qWeb and calling odoo defined templates like:


<template id="template_header_custom" inherit_id="website.layout" name="Template Header Cutsom" active="True">

<xpath expr="//header//nav" position="replace">

<h1>Custom header</h1>

<div>

<t t-call="website.navbar_nav">

<t t-set="_nav_class" t-valuef="me-auto"/>


<!-- Menu -->

<t t-foreach="website.menu_id.child_id" t-as="submenu">

<t t-call="website.submenu">

<t t-set="item_class" t-valuef="nav-item"/>

<t t-set="link_class" t-valuef="nav-link"/>

</t>

</t>

</t>

</div>

</xpath>

</template>

As soon as I invoque a website addon template I get the following error (once I've loaded the theme, navigate to the website home):


Error Message:
load could not load template ValueError: View 'website.navbar_nav' in website 1 not found Template: website.layout Path: /t/html/body/div/header/div[2]/t

How am I supposted to load these templates so I can create a custom dynamic layout for my theme?


0
Avatar
Abbandona
Luis H. Porras
Autore

Hi, thanks for the quick replay.

Yes in fact I've checked the three points:

  • website.navbar_nav template definition.
  • Manifest:

{

'name': 'Custom theme',

'description': 'Odoo custom theme',

'version': '1.0',

'author': 'Luis H. Porras',

'category': 'Theme/Creative',

'depends': ['website', 'website_theme_install'],

'data': [

'views/assets.xml',

'views/layout.xml',

'views/pages.xml',

'views/snippets.xml',

'views/options.xml'

],

}

  • And code correctess, well, the code it's been copy/pasted

So I understand from your replay that I'm doing the process as expected but for some reason I don't get the desired output. Searching in the design_themes repo I also found this approach but didn't work either:

theme_models.py

from odoo import models


class CustomTheme(models.AbstractModel):

_inherit = 'theme.utils'


@property

def _header_templates(self):

return ['theme_custom.template_header_custom'] + super()._header_templates


@property

def _footer_templates(self):

return ['theme_custom.template_footer_custom'] + super()._footer_templates


def _theme_custom_post_copy(self, mod):

self.enable_view('theme_custom.template_header_custom')

self.enable_view('theme_custom.template_footer_custom')

__init__.py (under models subfolder)

from . import theme_models

__init__.py (main folder)

from . import models

Any other ideas on how to debug this or any other workaround?

Thanks!

Avatar
Asliddin Maxmudov
Risposta migliore
  • Ensure Template Availability: Confirm that the website.navbar_nav and website.submenu templates exist in the website module. If they are not loaded or accessible, you won't be able to call them in your custom template.
  • Check for Module Dependencies: Make sure your custom theme module has a dependency on the website module. In the __manifest__.py file of your theme module, you should have:

'depends': ['website'],
  • Correct Template Call: Ensure that the template you're calling exists in the correct format and the call is made correctly. In your case, t-call="website.navbar_nav" and t-call="website.submenu" seem correct, but double-check that these templates are properly defined in the website module.
1
Avatar
Abbandona
Luis H. Porras
Autore

Hi, thanks for the quick replay.

Yes in fact I've checked the three points:

website.navbar_nav template definition.
Manifest:

{

'name': 'Custom theme',

'description': 'Odoo custom theme',

'version': '1.0',

'author': 'Luis H. Porras',

'category': 'Theme/Creative',

'depends': ['website', 'website_theme_install'],

'data': [

'views/assets.xml',

'views/layout.xml',

'views/pages.xml',

'views/snippets.xml',

'views/options.xml'

],

}

And code correctess, well, the code it's been copy/pasted

So I understand from your replay that I'm doing the process as expected but for some reason I don't get the desired output. Searching in the design_themes repo I also found this approach but didn't work either:

theme_models.py

from odoo import models

class CustomTheme(models.AbstractModel):

_inherit = 'theme.utils'

@property

def _header_templates(self):

return ['theme_custom.template_header_custom'] + super()._header_templates

@property

def _footer_templates(self):

return ['theme_custom.template_footer_custom'] + super()._footer_templates

def _theme_custom_post_copy(self, mod):

self.enable_view('theme_custom.template_header_custom')

self.enable_view('theme_custom.template_footer_custom')

__init__.py (under models subfolder)

from . import theme_models

__init__.py (main folder)

from . import models

Any other ideas on how to debug this or any other workaround?

Thanks!

Luis H. Porras
Autore

Hi Asliddin, I was re-reading your answer and wonder if there is a specific way of checking he availability of the templates in run-time as my response to your answer is based in checking the official repo code.

Avatar
Luis H. Porras
Autore Risposta migliore

Re-reading Asliddin answer I've found the  problem. 

In fact the template website.navbar_nav doesn't exist in Odoo v13.0 yet. My former link to  the code is pointing to a later version of Odoo.


0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How do I remove the numbers from the slugs in my blog and blogpost? Risolto
website
Avatar
Avatar
Avatar
Avatar
3
set 25
2685
Login Website Risolto
website
Avatar
3
ott 25
149265
500 Server Error after upgrading from 18.0 to 18.4 Odoo Online
website
Avatar
Avatar
1
set 25
2091
Can't delete website Risolto
website
Avatar
Avatar
Avatar
Avatar
Avatar
4
set 25
7050
How to Hide website Menus based on Groups
website
Avatar
Avatar
Avatar
2
ago 25
2218
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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