Hi,
I am completely new to development on Odoo mostly because of I needed some necessary features in Odoo that wasn't there and I could not find any where.
Anyway, I made a small module where you can mark a product to be visible to only logged in users. It worked for me in Odoo 14. but will not work in Odoo 16.
With a little help from one of our customers who had dabbled a bit with Odoo (but not with the web) help me find a fault in the xml-file in views so that a Boolean field is visible in the product view to make if the product should be visible or not for public users.
But even when it is set the product is still visible to public users and not hidden, so I suspect something has changed in the web view from Odoo 14 to Odoo 16, and I absolutely lost.
This is the code that I have in controllers that should control the webvisibility:
from odoo import http
from odoo.addons.website_sale.controllers.main import WebsiteSale
class WebsiteSaleProductVisibility(WebsiteSale):
def _get_search_domain(self, search, category, attrib_values):
domain = super(WebsiteSaleProductVisibility, self)._get_search_domain(search, category, attrib_values)
# Add extra search domain to filter products based on logged-in user status
if not http.request.env.user.has_group('base.group_user'):
domain += [('visible_to_logged_in_users_only', '=', False)]
return domain
If someone has a better knowledge of this than me I would appreciate a hit or two what I am missing and how to fix this. Of course this module will be freely available as soon as I get it work again.
Regards,
Lasse L...