This question has been flagged
2 Replies
1840 Views

Hello,

I am trying to inherit odoo 13  website main controllers index method. below is my code

from addons.website.controllers.main import Website
from odoo import http
from odoo.http import request


class WebsiteSort(Website):
@http.route(auth='public')
def index(self, **kw):
super(WebsiteSort, self).index()

website_product_ids = request.env['product.template'].search([('is_published', '=', True)])
return request.render('website.homepage', {
'website_product_ids': website_product_ids
})


When I debug with PyCharm I can see that the parent method executes but not my inherited method. It's not even calling super()! I have properly imported .py in __init__.py file.


Appreciate your help. Thank you



Avatar
Discard
Best Answer

Hi,

please try with the below solution, you forgot to add argument in Super Call


super(WebsiteSort, self).index(**kw)

Thanks & Regards,
Sunny Sheth

Avatar
Discard
Author Best Answer

Hi Sunny,

Thank for your reply, I included the argument but it is not the case!

The whole inherited method is not being called (The code below super) so I can't get the published product list to the home page, which I want to display products not only in shop page but also on home page.

any other suggestions.

Kind regards

Suraj


Avatar
Discard