Siirry sisältöön
Odoo Menu
  • Kirjaudu sisään
  • Kokeile ilmaiseksi
  • Sovellukset
    Talous
    • Kirjanpito
    • Laskutus
    • Kulut
    • Datataulukot (BI)
    • Asiakirjat
    • Allekirjoita
    Myynti
    • CRM
    • Myynti
    • Kassajärjestelmä myymälään
    • Kassajärjestelmä ravintolaan
    • Tilaukset
    • Vuokraus
    Verkkosivut
    • Verkkosivun Rakennustyökalu
    • Verkkokauppa
    • Blogi
    • Foorumi
    • Livechat
    • Verkko-oppiminen
    Toimitusketju
    • Varastointi
    • Tuotanto
    • Tuotteen elinkaaren hallinta (PLM)
    • Ostot
    • Huolto
    • Laatu
    Henkilöstöhallinto
    • Työntekijät
    • Rekrytointi
    • Vapaat
    • Arvioinnit
    • Suositukset
    • Kuljetuskalusto
    Markkinointi
    • Somemarkkinointi
    • Sähköpostimarkkinointi
    • Tekstiviestimarkkinointi
    • Tapahtumat
    • Markkinoinnin automaatio
    • Kyselyt
    Palvelut
    • Projekti
    • Työaikakirjaukset
    • Kenttähuolto
    • Asiakaspalvelu
    • Suunnittelu
    • Ajanvaraukset
    Tuottavuus
    • Viestintä
    • Hyväksynnät
    • IoT
    • IP-puhe
    • Tietokirjasto
    • WhatsApp
    Kolmannen osapuolen sovellukset Odoo-Studio Odoo-Pilvialusta
  • Toimialat
    Vähittäiskauppa
    • Kirjakauppa
    • Vaatekauppa
    • Huonekaluliike
    • Ruokakauppa
    • Laitteistokauppa
    • Lelukauppa
    Ruoka & Majoitus
    • Baari ja Pubi
    • Ravintola
    • Pikaruoka
    • Majatalo
    • Juomien jakelija
    • Hotelli
    Kiinteistöt
    • Kiinteistönvälitystoimisto
    • Arkkitehtitoimisto
    • Rakentaminen
    • Kiinteistönhallinta
    • Puutarhanhoito
    • Kiinteistön omistajien yhdistys
    Konsultointi
    • Tilitoimisto
    • Odoo-kumppani
    • Markkinointitoimisto
    • Lakitoimisto
    • Osaajahankinta
    • Tilintarkastus & sertifiointi
    Tuotanto
    • Tekstiili
    • Metalli
    • Huonekalut
    • Ruoka
    • Panimo
    • Yrityslahjat
    Terveys & Liikunta
    • Urheiluseura
    • Silmälasiliike
    • Kuntokeskus
    • Hyvinvointialan ammattilaiset
    • Apteekki
    • Kampaamo
    Kaupat
    • Yleismies
    • IT-laitteisto & Tuki
    • Aurinkoenergiajärjestelmät
    • Suutari
    • Siivouspalvelut
    • LVI-palvelut
    Muut
    • Voittoa tavoittelematon järjestö
    • Ympäristötoimisto
    • Mainostaulujen vuokraus  
    • Valokuvaus
    • Leasing-pyörät
    • Ohjelmistojen jälleenmyyjä
    Selaa kaikkia toimialoja
  • Yhteisö
    Opi
    • Kurssit
    • Dokumentaatio
    • Todistukset
    • Koulutus
    • Blogi
    • Podcast
    Kannusta kouluttautumaan
    • Koulutusohjelmat
    • Scale Up! Liiketoimintapeli
    • Vieraile Odoolla
    Hanki ohjelmisto
    • Lataa
    • Vertaile versioita
    • Julkaisut
    Tee yhteistyötä
    • Github
    • Foorumi
    • Tapahtumat
    • Käännökset
    • Ryhdy kumppaniksi
    • Kumppanipalvelut
    • Rekisteröi tilitoimistosi
    Hanki palveluja
    • Löydä kumppani
    • Löydä kirjanpitäjä
    • Varaa asiantuntijatapaaminen
    • Implementaatiopalvelut
    • Asiakasreferenssit
    • Tuki
    • Versionkorotukset
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Varaa demo
  • Hinnoittelu
  • Asiakaspalvelu

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

  • CRM
  • e-Commerce
  • Kirjanpito
  • Varastointi
  • PoS
  • Projekti
  • MRP
All apps
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Apua

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

Tilaa

Saat ilmoituksen, kun tähän viestiin ilmaantuu aktiviteettia

Tämä kysymys on merkitty
logincontrollershttp.route
2 Vastaukset
5761 Näkymät
Avatar
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
Avatar
Hylkää
Avatar
AGILE BUSINESS TECHNOLOGIES
Tekijä Paras vastaus

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
Avatar
Hylkää
Avatar
Waleed Ali Mohsen
Paras vastaus

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
Avatar
Hylkää
AGILE BUSINESS TECHNOLOGIES
Tekijä

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.

Nautitko keskustelusta? Älä vain lue, vaan osallistu!

Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!

Rekisteröidy
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
log in controller with react
login controllers
Avatar
0
marrask. 23
2274
Controller ignoring args Ratkaistu
controllers arguments http.route
Avatar
Avatar
Avatar
2
jouluk. 22
8810
Properly inherit web controller and overwrite web_login method Ratkaistu
inheritance login controllers
Avatar
Avatar
Avatar
3
toukok. 21
14942
Force authentication of a web page
login controllers odoo
Avatar
Avatar
1
marrask. 20
7405
Controller giving 404 Error
controllers
Avatar
Avatar
Avatar
2
elok. 25
3594
Yhteisö
  • Kurssit
  • Dokumentaatio
  • Foorumi
Avoin lähdekoodi
  • Lataa
  • Github
  • Runbot
  • Käännökset
Palvelut
  • Odoo.sh hosting
  • Tuki
  • Versionkorotus
  • Räätälöidyt kehitykset
  • Koulutus
  • Löydä kirjanpitäjä
  • Löydä kumppani
  • Ryhdy kumppaniksi
Meistä
  • Yrityksemme
  • Brändiominaisuudet
  • Ota yhteyttä
  • Työpaikat
  • Tapahtumat
  • Podcast
  • Blogi
  • Asiakkaat
  • Oikeudellinen ilmoitus • Yksityisyys
  • Tietoturva
الْعَرَبيّة 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 on kokoelma avoimen lähdekoodin yrityssovelluksia, jotka kattavat kaikki yrityksesi tarpeet: asiakkuudenhallinta eli CRM, verkkokauppa, kirjanpito, varastointi, kassajärjestelmä, projektinhallinta, jne.

Odoon uniikki arvolupaus on olla samanaikaisesti erittäin helppokäyttöinen ja täysin integroitu.

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