콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
13905 화면

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..



아바타
취소
베스트 답변

Hi,

Replace this line

        ensure_db()

as,

        main.ensure_db()

Thanks
아바타
취소
작성자

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

베스트 답변

Excellent

아바타
취소
관련 게시물 답글 화면 활동
0
11월 23
1259
2
5월 22
4185
1
11월 20
6072
1
2월 16
6532
2
8월 20
10882