Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to pass context data to the main template webclient_bootstrap to use in menu?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
templatescontextOdoo13.0
8282 Widoki
Awatar
Samo Arko

I have a custom module on my odoo server that clients need to pay extra for use, but they can use it for free as a demo for a month. On install the module creates an entry in demo.installation model, where the module name and date of install are saved.

From the date I've got a "timer". I need to show the timer in the menu. I've badly extended the menu following this question https://www.odoo.com/forum/help-1/question/odoo10-how-to-inherit-templates-of-web-module-119140


I now need to show the remaining days in the menu.

I've override the web.Home controllers web_client method to check and add to the context.


@http.route('/web', type='http', auth="none")
def web_client(self, s_action=None, **kw):
	ensure_db()
	if not request.session.uid:
		return werkzeug.utils.redirect('/web/login', 303)
	if kw.get('redirect'):
		return werkzeug.utils.redirect(kw.get('redirect'), 303)

	request.uid = request.session.uid

	# DODELAVA ZA TIMER
	demo_install = request.env['demo.installation'].search([])
	try:
		context = request.env['ir.http'].webclient_rendering_context()
	except:
		return werkzeug.utils.redirect('/web/login?error=access')

	if len(demo_install) > 0:
		demo_install = demo_install[0]

		demos_obj = self.get_expiration_dict(demo_install)
		# NE DELUJEJO COMPUTED POLJA
		if demos_obj['expires'] < 0:
			msg = u'Your demo time is over! The module will be deleted in {} days!'.format(demos_obj['deletes'])
			context['message'] = msg
			return request.render('odoo13_demo_timer.expiry_message', qcontext=context)
		else:
			demos_obj['message'] = u'Your demo will end in {} days. The module will be deleted in {} days!'.format(demos_obj['expires'], demos_obj['deletes'])
			if demos_obj['expires'] <= 2:
				demos_obj['message_class'] = 'red'
			elif demos_obj['expires'] <= 7:
				demos_obj['message_class'] = 'yellow'
			elif demos_obj['expires'] > 7:
				demos_obj['message_class'] = 'green'

		context['demo_timer'] = demos_obj

	try:
		response = request.render('web.webclient_bootstrap', qcontext=context)
		response.headers['X-Frame-Options'] = 'DENY'
		return response
	except AccessError:
		return werkzeug.utils.redirect('/web/login?error=access')


The menu templet looks like

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">


<t t-extend="Menu">

    <t t-jquery='.o_menu_sections' t-operation='after'>

        <t t-if="demo_timer">

            <ul class="nav navbar-nav navbar-right demo_time_placeholder">

                <li t-attf-class="{{ demo_timer['message_class'] }}"><t t-esc="demo_timer['message']" /></li>

            </ul>

        </t>

        <ul class="full">FOO BAR</ul>

    </t>

</t>


</templates>


The problem is that there is no section "demo_timer" in the context that is passed to the template. 

How can I pass values in context so I can use them in the menu?

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Odoo v13 : Website theming - custom page not displayed
templates Odoo13.0 theming
Awatar
Awatar
1
cze 24
4070
Odoo13 External ID not found in the system: account.model_account_invoice Rozwiązane
templates emailtemplate odoo12 Odoo13.0
Awatar
Awatar
1
kwi 20
7574
context not work ???
context
Awatar
Awatar
1
sty 25
2084
"harmonised" template for various use cases
templates
Awatar
0
lip 24
2176
Odoo 13. Don't close a wizard when Click a button Rozwiązane
Odoo13.0
Awatar
Awatar
Awatar
Awatar
4
maj 24
14075
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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