Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Нерухомість
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

Using qWeb templates in custom website theme

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
website
2 Відповіді
3291 Переглядів
Аватар
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
Аватар
Відмінити
Luis H. Porras
Автор

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!

Аватар
Asliddin Maxmudov
Найкраща відповідь
  • 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
Аватар
Відмінити
Luis H. Porras
Автор

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
Автор

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.

Аватар
Luis H. Porras
Автор Найкраща відповідь

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
Аватар
Відмінити
Enjoying the discussion? Don't just read, join in!

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

Реєстрація
Related Posts Відповіді Переглядів Дія
How do I remove the numbers from the slugs in my blog and blogpost? Вирішено
website
Аватар
Аватар
Аватар
Аватар
3
вер. 25
2685
Login Website Вирішено
website
Аватар
3
жовт. 25
149265
500 Server Error after upgrading from 18.0 to 18.4 Odoo Online
website
Аватар
Аватар
1
вер. 25
2091
Can't delete website Вирішено
website
Аватар
Аватар
Аватар
Аватар
Аватар
4
вер. 25
7049
How to Hide website Menus based on Groups
website
Аватар
Аватар
Аватар
2
серп. 25
2218
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція Odoo - це одночасно дуже проста у використанні та повністю інтегрована.

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