Skip to Content
Menu
This question has been flagged

I want to inherit the '/web/login' controller but the problem is when my function return, the control goes to the method who has also inherit and then it return their functionality instead of my functionality.
Let me give example what is happening in my case when 'website' module is also installed.

# my custome module code
class myClass(Home):
    @http.route() def web_login(self, redirect=None, *args, **kw):
    _logger.info('1')
    response = super(myClass, self).web_login(redirect=redirect, *args, **kw)
    _logger.info('2')
    return request.render('myModule.myTemplate', data)

# Odoo file located at ../odoo/addons/website/controllers/main.py
class Website(Home):
    @http.route(website=True, auth="public") def web_login(self, redirect=None, *args, **kw): logger.debug('3') response = super(Website, self).web_login(redirect=redirect, *args, **kw) if not redirect and request.params['login_success']: if request.env['res.users'].browse(request.uid).has_group('base.group_user'): redirect = '/web?' + request.httprequest.query_string else: redirect = '/' logger.debug('4') return http.redirect_with_hash(redirect) logger.debug('5') return response

The output is:

1
2
3
4
So basically instead of rendering myModule.myTemplate template which is after logger label as '2', the control goes to website module and it return http.redirect_with_hash(redirect) which is after logger label as '4'.
How to achieve this so that no matter whoever the method is last but it should always return my code which is myModule.myTemplate.

It will be very helpful which you share example code to solve this issue. If anything which need some more clarification then let me know. I will try to explain more.

PS: My custom module can only depend on web module, so I can't add dependency to website module to overcome the solution. However, we can install website module later, Just saying considering this issue can only solve by understanding this solution: \https://www.odoo.com/forum/help-1/question/v8-general-question-about-method-inheritance-multiple-override-in-different-modules-100032

Avatar
Discard
Best Answer

Hello @Vinay,


What you are doing here is that you are calling super method of the parent controller that you have inherited, here in ODOO's method you can see that return is not a data (JSON) but a redirection.


here's the solution:


Copy the whole method of ODOO base and override it by adding your code where required and don't call super now. This way it will have its original functionality + your customised flow.


Hope it helps.

Regards,




Email:     odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Avatar
Discard
Related Posts Replies Views Activity
3
Jul 18
2602
0
Sep 22
2475
0
Jan 22
1527
1
May 24
3390
3
May 21
12924