Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
14042 Zobrazení

Dear Team,

I am trying to overwrite web_login method in web controller Main class but somehow its not working for me..

Here is my code I used to do this..


import odoo.addons.web.controllers.main as main

import datetime import pytz

class Home(main.Home):

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

request.params['login_success'] = False
if request.httprequest.method == 'GET' and redirect and request.session.uid:
return http.redirect_with_hash(redirect)
...
....
(Entire method as it is...with some customization..)
...


On trying to login, this method is properly called replacing the default web_login().. but giving error as below..

ensure_db()
NameError: global name 'ensure_db' is not defined

What I am missing as its not finding ensure_db() ?? If I copy-paste ensure_db() here in my inherited,, it will again ask or another dependency ???

Please advice the correct way to overwrite ??
I just have couple of lines to be changed here... and keep entire method as it is..


Appreciate support team...

Thanks in advance..



Avatar
Zrušit
Nejlepší odpověď

Hi,

Replace this line

        ensure_db()

as,

        main.ensure_db()

Thanks
Avatar
Zrušit
Autor

Great.. Thanks.. It worked.. ;)

Nejlepší odpověď

Excellent

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
lis 23
1397
2
kvě 22
4432
1
lis 20
6296
1
úno 16
6693
2
srp 20
11061