diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index ccd9223e..24ffbf13 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -239,7 +239,6 @@ class WebsiteSale(http.Controller):
compute_currency, pricelist_context, pricelist = self._get_compute_currency_and_context()
request.context = dict(request.context, pricelist=pricelist.id, partner=request.env.user.partner_id)
-
url = "/shop"
if search:
post["search"] = search
@@ -252,7 +251,34 @@ class WebsiteSale(http.Controller):
if attrib_list:
post['attrib'] = attrib_list
- categs = request.env['product.public.category'].search([('parent_id', '=', False), ('website_ids', 'in', request.website.id)])
+ current_partner_tags = request.context['partner'].category_id
+ partner_child_tags = request.env['res.partner.category'].search(
+ [('parent_id', 'in', current_partner_tags.ids)])
+
+ if not request.env.user.has_group('website.group_website_publisher'):
+ categs = request.env['product.public.category'].search(
+ [('parent_id', '=', False),
+ ('website_ids', 'in', request.website.id),
+ '|', ('partner_tag_ids', 'in',
+ current_partner_tags.ids + partner_child_tags.ids),
+ ('partner_tag_ids', '=', False)])
+ else:
+ categs = request.env['product.public.category'].search(
+ [('parent_id', '=', False),
+ ('website_ids', 'in', request.website.id)])
+
+ categs_with_childs = request.env['product.public.category'].search(
+ [('website_ids', 'in', request.website.id),
+ '|', ('partner_tag_ids', 'in',
+ current_partner_tags.ids + partner_child_tags.ids),
+ ('partner_tag_ids', '=', False)])
+
+ parent_categ_with_childs = request.env['product.public.category'].\
+ search([('parent_id', 'in', categs_with_childs.ids),
+ '|', ('partner_tag_ids', 'in',
+ current_partner_tags.ids + partner_child_tags.ids),
+ ('partner_tag_ids', '=', False)])
+
Product = request.env['product.template']
parent_category_ids = []
@@ -263,10 +289,16 @@ class WebsiteSale(http.Controller):
parent_category_ids.append(current_category.parent_id.id)
current_category = current_category.parent_id
+ if not request.env.user.has_group('website.group_website_publisher') \
+ and (categs_with_childs or parent_categ_with_childs):
+ domain += ['|', '&',
+ ('public_categ_ids', 'in', categs_with_childs.ids),
+ ('public_categ_ids', 'in', parent_categ_with_childs.ids),
+ ('public_categ_ids', '=', False)]
+
product_count = Product.search_count(domain)
pager = request.website.pager(url=url, total=product_count, page=page, step=ppg, scope=7, url_args=post)
products = Product.search(domain, limit=ppg, offset=pager['offset'], order=self._get_search_order(post))
-
ProductAttribute = request.env['product.attribute']
ProductBrand = request.env['product.brand']
ProductTag = request.env['product.tags']
@@ -302,6 +334,8 @@ class WebsiteSale(http.Controller):
'bins': TableCompute().process(products, ppg),
'rows': PPR,
'categories': categs,
+ 'categories_with_child': categs_with_childs.ids +
+ parent_categ_with_childs.ids,
'attributes': attributes,
'compute_currency': compute_currency,
'keep': keep,
diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py
index 83a5b296..7f98d048 100644
--- a/addons/website_sale/models/product.py
+++ b/addons/website_sale/models/product.py
@@ -131,6 +131,17 @@ class ProductPublicCategory(models.Model):
string='Websites', copy=False,
help='List of websites in which '
'category will published.')
+ partner_tag_ids = fields.Many2many('res.partner.category',
+ 'partner_public_categ_tags_rel',
+ 'tag_id', 'category_id',
+ string='Partner Tags',
+ help='If logged in customers/partners '
+ 'have this tag then this product '
+ 'category will appear to them in '
+ 'E-commerce website.\n\n'
+ 'If empty then it becomes general '
+ 'category which display to any '
+ 'customers/partners.')
@api.model
def create(self, vals):
diff --git a/addons/website_sale/security/ir.model.access.csv b/addons/website_sale/security/ir.model.access.csv
index 1a780c75..e425b8ba 100644
--- a/addons/website_sale/security/ir.model.access.csv
+++ b/addons/website_sale/security/ir.model.access.csv
@@ -22,3 +22,4 @@ access_product_view_limit,access_product_view_limit,model_product_view_limit,,1,
access_product_ribbon,product_ribbon,model_product_ribbon,,1,0,0,0
access_product_tags,access_product_tags,model_product_tags,,1,0,0,0
access_product_brand,access_product_brand,model_product_brand,,1,0,0,0
+access_res_partner_category_group_public,res_partner_category_group_public,base.model_res_partner_category,,1,0,0,0
diff --git a/addons/website_sale/views/product_views.xml b/addons/website_sale/views/product_views.xml
index 15f9a999..6bb59e4e 100644
--- a/addons/website_sale/views/product_views.xml
+++ b/addons/website_sale/views/product_views.xml
@@ -156,6 +156,7 @@
+
diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml
index 2062fdc1..cfc4e59c 100644
--- a/addons/website_sale/views/templates.xml
+++ b/addons/website_sale/views/templates.xml
@@ -362,7 +362,13 @@
-
+
+
+
+
+
+
+