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

Overriding route for /web/login path produces ValueError: Expected singleton: res.users()

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
logincontrollershttp.route
2 Odpowiedzi
5769 Widoki
Awatar
AGILE BUSINESS TECHNOLOGIES

We are trying to override the default controller for the /web/login route in odoo/addons/web/controllers/main.py

The custom code is as follows:


from odoo import http
from odoo.addons.web.controllers.main import Home


class ProductivityCardHome(Home):

@http.route('/web/login', type='http', auth="none")
def web_login(self, redirect=None, **kw):
res = super(ProductivityCardHome, self).web_login(redirect=redirect, kw=kw)
return res

Unfortunately, the code above results in the following errors that we don't know what is the cause.



Traceback (most recent call last):
File "/project/src/odoo/odoo/models.py", line 5199, in ensure_one
_id, = self._ids
ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
yield from compiled_fn(self, values, log)
File "", line 5, in template_1741
File "/project/src/odoo/addons/website_sale_stock/models/website.py", line 28, in sale_get_order
so = super().sale_get_order(force_create=force_create, code=code, update_pricelist=update_pricelist, force_pricelist=force_pricelist)
File "/project/src/odoo/addons/website_sale/models/website.py", line 250, in sale_get_order
if not sale_order_id and not self.env.user._is_public():
File "/project/src/odoo/odoo/addons/base/models/res_users.py", line 905, in _is_public
self.ensure_one()
File "/project/src/odoo/odoo/models.py", line 5202, in ensure_one
raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: res.users()

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/project/src/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/project/src/odoo/odoo/http.py", line 810, in dispatch
r = self._call_function(**self.params)
File "/project/src/odoo/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/project/src/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/project/src/odoo/odoo/http.py", line 351, in checked_call
result.flatten()
File "/project/src/odoo/odoo/http.py", line 1277, in flatten
self.response.append(self.render())
File "/project/src/odoo/odoo/http.py", line 1270, in render
return env["ir.ui.view"]._render_template(self.template, self.qcontext)
File "/project/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 1980, in _render_template
return self.browse(self.get_view_id(template))._render(values, engine)
File "/project/src/odoo/addons/website/models/ir_ui_view.py", line 433, in _render
return super(View, self)._render(values, engine=engine, minimal_qcontext=minimal_qcontext)
File "/project/src/odoo/addons/web_editor/models/ir_ui_view.py", line 29, in _render
return super(IrUiView, self)._render(values=values, engine=engine, minimal_qcontext=minimal_qcontext)
File "/project/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 1988, in _render
return self.env[engine]._render(self.id, qcontext)
File "/project/src/odoo/odoo/tools/profiler.py", line 289, in _tracked_method_render
return method_render(self, template, values, **options)
File "/project/src/odoo/odoo/addons/base/models/ir_qweb.py", line 76, in _render
result = super()._render(template, values=values, **compile_options)
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 134, in _render
result = ''.join(rendering)
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 221, in render_template
raise e
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
yield from compiled_fn(self, values, log)
File "", line 186, in template_190
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 221, in render_template
raise e
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
yield from compiled_fn(self, values, log)
File "", line 29, in template_189
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 221, in render_template
raise e
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
yield from compiled_fn(self, values, log)
File "", line 1222, in template_1388
File "", line 1157, in t_call_content
File "", line 1109, in t_call_content
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 223, in render_template
raise QWebException("Error when render the template", self, options,
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/project/src/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/project/src/odoo/odoo/http.py", line 810, in dispatch
r = self._call_function(**self.params)
File "/project/src/odoo/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/project/src/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/project/src/odoo/odoo/http.py", line 351, in checked_call
result.flatten()
File "/project/src/odoo/odoo/http.py", line 1277, in flatten
self.response.append(self.render())
File "/project/src/odoo/odoo/http.py", line 1270, in render
return env["ir.ui.view"]._render_template(self.template, self.qcontext)
File "/project/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 1980, in _render_template
return self.browse(self.get_view_id(template))._render(values, engine)
File "/project/src/odoo/addons/website/models/ir_ui_view.py", line 433, in _render
return super(View, self)._render(values, engine=engine, minimal_qcontext=minimal_qcontext)
File "/project/src/odoo/addons/web_editor/models/ir_ui_view.py", line 29, in _render
return super(IrUiView, self)._render(values=values, engine=engine, minimal_qcontext=minimal_qcontext)
File "/project/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 1988, in _render
return self.env[engine]._render(self.id, qcontext)
File "/project/src/odoo/odoo/tools/profiler.py", line 289, in _tracked_method_render
return method_render(self, template, values, **options)
File "/project/src/odoo/odoo/addons/base/models/ir_qweb.py", line 76, in _render
result = super()._render(template, values=values, **compile_options)
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 134, in _render
result = ''.join(rendering)
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 221, in render_template
raise e
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
yield from compiled_fn(self, values, log)
File "", line 186, in template_190
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 221, in render_template
raise e
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
yield from compiled_fn(self, values, log)
File "", line 29, in template_189
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 221, in render_template
raise e
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
yield from compiled_fn(self, values, log)
File "", line 1222, in template_1388
File "", line 1157, in t_call_content
File "", line 1109, in t_call_content
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 223, in render_template
raise QWebException("Error when render the template", self, options,
odoo.addons.base.models.qweb.QWebException: Expected singleton: res.users()
Traceback (most recent call last):
File "/project/src/odoo/odoo/models.py", line 5199, in ensure_one
_id, = self._ids
ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/project/src/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
yield from compiled_fn(self, values, log)
File "", line 5, in template_1741
File "/project/src/odoo/addons/website_sale_stock/models/website.py", line 28, in sale_get_order
so = super().sale_get_order(force_create=force_create, code=code, update_pricelist=update_pricelist, force_pricelist=force_pricelist)
File "/project/src/odoo/addons/website_sale/models/website.py", line 250, in sale_get_order
if not sale_order_id and not self.env.user._is_public():
File "/project/src/odoo/odoo/addons/base/models/res_users.py", line 905, in _is_public
self.ensure_one()
File "/project/src/odoo/odoo/models.py", line 5202, in ensure_one
raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: res.users()

Error when render the template
ValueError: Expected singleton: res.users()
Template: website_sale.header_cart_link
Path: /t/t[1]
Node:


0
Awatar
Odrzuć
Awatar
AGILE BUSINESS TECHNOLOGIES
Autor Najlepsza odpowiedź

We figured it out. The working code is:

# -*- coding: utf-8 -*-
from
odoo import http
from odoo.addons.web.controllers import main


class Home(main.Home):

@http.route('/web/login')
def web_login(self, *args, **kw):
return super().web_login(*args, **kw)



Apparently, the web_login method was also modified in the website module to add some options to the http.route decorator for public access purposes which makes sense when you have the website module installed.
The cause of the error we are getting is that we undid the changes made by the website module by re-setting the options of the http.route decorator in our custom code. As noticed in the working code above, we removed those options.


0
Awatar
Odrzuć
Awatar
Waleed Ali Mohsen
Najlepsza odpowiedź

Try the below:

 @http.route('/web/login', type='http', auth="none")
def web_login(self, redirect=None, **kw):
res = super(ProductivityCardHome, self).web_login(redirect=redirect, **kw)
return res


1
Awatar
Odrzuć
AGILE BUSINESS TECHNOLOGIES
Autor

Hi @Waleed. Thank you for taking the time to answer our question. We updated the code as you suggested but still getting the same error.

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ść
log in controller with react
login controllers
Awatar
0
lis 23
2274
Controller ignoring args Rozwiązane
controllers arguments http.route
Awatar
Awatar
Awatar
2
gru 22
8810
Properly inherit web controller and overwrite web_login method Rozwiązane
inheritance login controllers
Awatar
Awatar
Awatar
3
maj 21
14942
Force authentication of a web page
login controllers odoo
Awatar
Awatar
1
lis 20
7405
Controller giving 404 Error
controllers
Awatar
Awatar
Awatar
2
sie 25
3594
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