Skip to Content
Menu
This question has been flagged
2 Replies
1666 Views

Hello all, 

in Ecommerce, we have the option to enable Ecommerce Categories, When set true it will show a list of defined categories and their related products. My question is:

Suppose we have category 1 , sub category 1 as child of category 1. Cat 2, sub Cat 2 ... 

let's say a user clicks on cat 1 or sub cat 1.... I want to hide the rest of the categories. 

how to do that in Odoo, still new to the js framework of odoo and i don't have so much time left to finish the task.

i tried to create a new /shop page but with no luck ( kept giving internal server error) 

Thanks in advance,

 

 

Avatar
Discard
Best Answer

File "d:\work\odoo\addons\sunlake_sale\controllers\website_sale.py", line 13, in SunlakeWebsiteSaleExt
], type='http', auth="public", website=True, sitemap=sitemap_shop) #, sitemap=sitemap_shop
NameError: name 'sitemap_shop' is not defined -

And i replaced the Extension class with SunlakeWebsiteSaleExt at the last line

Avatar
Discard
Best Answer

Hello there, 

You can achieve this requirement by inheriting shop controller like below

    @http.route([

        '''/shop''',

        '''/shop/page/<int:page>''',

        '''/shop/category/<model("product.public.category"):category>''',

        '''/shop/category/<model("product.public.category"):category>/page/<int:page>'''

    ], type='http', auth="public", website=True, sitemap=sitemap_shop)

    def shop(self, page=0, category=None, search='', ppg=False, **post):

        res = super(WebsiteSale, self).shop(page, category, search, ppg, post)

        res.qcontext['categories'] = [] if category else res.qcontext.get('categories')

        return res

Thanks

Anisha Bahukhandi

Avatar
Discard

I tried this, but the sitemap parameter causes error. How do you solved that?

from openerp import http
from openerp.http import request
import openerp.addons.website_sale.controllers.main as main

class SunlakeWebsiteSaleExt(main.WebsiteSale):

@http.route([
'''/shop''',
'''/shop/page/<int:page>''',
'''/shop/category/<model("product.public.category"):category>''',
'''/shop/category/<model("product.public.category"):category>/page/<int:page>'''
], type='http', auth="public", website=True) #, sitemap=sitemap_shop
def shop(self, page=0, category=None, search='', ppg=False, **post):
things_to_do_here
return super(Extension, self).report_download(page, category, search, ppg, post)