Перейти к содержимому
Odoo Меню
  • Войти
  • Попробовать бесплатно
  • Модули
    Финансы
    • Бухгалтерия
    • Выставление счетов
    • Расходы
    • Таблицы
    • Документооборот
    • Подпись
    Продажи
    • CRM
    • Продажи
    • POS Магазин
    • POS Ресторан
    • Подписки
    • Аренда
    Вебсайты
    • Конструктор вебсайтов
    • eCommerce
    • Блог
    • Форум
    • Онлайн-чат
    • Электронное обучение
    Логистика
    • Склад
    • Производство
    • PLM
    • Закупки
    • Обслуживание
    • Качество
    Отдел кадров
    • Сотрудники
    • Подбор персонала
    • Отпуска
    • Оценка персонала
    • Реферальная программа
    • Автопарк
    Маркетинг
    • SMM
    • E-mail рассылки
    • СМС рассылки
    • Мероприятия
    • Автоматизация маркетинга
    • Опросы
    Услуги
    • Проекты
    • Табели
    • Выездной сервис
    • Поддержка
    • Планирование
    • Встречи
    Продуктивность
    • Обсуждения
    • Согласование
    • IoT
    • VoIP-телефония
    • Knowledge
    • WhatsApp
    Сторонние приложения Модуль Студия Odoo Платформа Odoo Cloud
  • Индустрии
    Розничная торговля
    • Книжный магазин
    • Магазин одежды
    • Мебельный магазин
    • Продуктовый магазин
    • Строительный магазин
    • Магазин игрушек
    Гостинично-ресторанный бизнес
    • Бар и паб
    • Ресторан
    • Фастфуд
    • Гостевой дом
    • Дистрибьютор напитков
    • Отель
    Недвижимость
    • Агентство недвижимости
    • Архитектурное бюро
    • Строительство
    • Управление недвижимостью
    • Ландшафтный дизайн
    • Товарищество собственников жилья
    Консалтинг
    • Бухгалтерская фирма
    • Партнер Odoo
    • Маркетинговое агентство
    • Юридическая фирма
    • Подбор персонала
    • Аудиторское бюро
    Производство
    • Текстиль
    • Металл
    • Мебель
    • Продукты питания
    • Пивоварня
    • Корпоративные сувениры
    Здоровье и фитнес
    • Спортивный комплекс
    • Магазин оптики
    • Фитнес-клуб
    • Велнес-центр
    • Аптека
    • Салон красоты
    Услуги
    • Специалист по бытовым услугам
    • Продажа и обслуживание IT-оборудования
    • Солнечные энергосистемы
    • Производство обуви
    • Клининг
    • Системы ОВКВ
    Прочее
    • Некоммерческая организация
    • Консалтинг в сфере устойчивого развития
    • Аренда рекламных щитов
    • Бизнес по фотосъемке
    • Прокат велосипедов
    • Реселлер программного обеспечения
    Все индустрии
  • Community
    Обучение
    • Видео уроки
    • Документация
    • Сертификация
    • Тренинг
    • Блог
    • Подкаст
    Образование и развитие
    • Образовательная программа
    • Деловая игра Scale Up!
    • Экскурсия в офис Odoo
    ПО
    • Скачать
    • Сравнить версии
    • Релизы
    Сотрудничество
    • Github
    • Форум
    • Мероприятия
    • Перевод
    • Стать партнером
    • Услуги для партнеров
    • Зарегистрировать бухгалтерскую фирму
    Услуги
    • Найти партнера
    • Найти бухгалтера
    • Встреча с экспертом
    • Услуги по внедрению
    • Отзывы клиентов
    • Поддержка
    • Обновления
    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
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Все посты Люди Значки
Теги (Смотреть все)
odoo accounting v14 pos v15
Об этом форуме
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Все посты Люди Значки
Теги (Смотреть все)
odoo accounting v14 pos v15
Об этом форуме
Помощь

Using qWeb templates in custom website theme

Подписаться

Получайте уведомления о появлении активности в этом посте

Этот вопрос был отмечен
website
2 Ответы
3284 Представления
Аватар
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
Аватар
Отменить
Не оставайтесь в стороне – присоединяйтесь к обсуждению!

Создайте аккаунт сегодня, чтобы получить доступ к эксклюзивным функциям и стать частью нашего замечательного сообщества!

Регистрация
Похожие посты Ответы Просмотры Активность
How do I remove the numbers from the slugs in my blog and blogpost? Решено
website
Аватар
Аватар
Аватар
Аватар
3
сент. 25
2684
Login Website Решено
website
Аватар
3
окт. 25
149265
500 Server Error after upgrading from 18.0 to 18.4 Odoo Online
website
Аватар
Аватар
1
сент. 25
2088
Can't delete website Решено
website
Аватар
Аватар
Аватар
Аватар
Аватар
4
сент. 25
7045
How to Hide website Menus based on Groups
website
Аватар
Аватар
Аватар
2
авг. 25
2213
Сообщество
  • Видео уроки
  • Документация
  • Форум
Открытый исходный код
  • Скачать
  • Github
  • Runbot
  • Перевод
Услуги
  • Хостинг Odoo.sh
  • Поддержка
  • Обновление
  • Индивидуальные решения по доработке
  • Образование
  • Найти бухгалтера
  • Найти партнера
  • Стать партнером
О нас
  • Наша компания
  • Активы бренда
  • Cвяжитесь с нами
  • Вакансии
  • Мероприятия
  • Подкаст
  • Блог
  • Клиенты
  • Правовые документы • Конфиденциальность
  • Безопасность
الْعَرَبيّة 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, E-commerce, Бухгалтерия, Склад, POS, управление проектами и др.

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