This question has been flagged
9 Replies
40203 Views

I would like to set up a B2B platform on my stunning Odoo website. To achieve this, I want to hide the Shop menu and the ecommerce content (product pages, etc) for all the unregistered website visitors. How can I do this?

Avatar
Discard

Hi does this still work in Odoo 14


Kind regards and have a nice evening 

Author Best Answer
  1. How to hide the "Shop" menu item? Go to Settings > Technical > Security > Record rules and create a new rule:

    • Object: Website Menu
    • Apply for Read access
    • Rule definition: [('url','not like','%/shop%')]
    • Group: Public
  2. How to make the eCommerce pages unreachable for people who are not registered as employees or portal users?

    • Open your shop and access the page HTML editor
    • Select the Product page
    • Add the following attribute in the first <t> tag (name="Products"): groups="base.group_user,base.group_portal"

Now you can open your website as an anonymous person. You do not retrieve the Shop menu and if you try to reach yourdatabasename/shop, you get an empty page.

Avatar
Discard

Hi Frédéric, Thanks for your post. Could this be applied in a similar manner to the following elements on the frontend: Add to Cart Shopping Cart (in header) Sales Price Quantity (ie. - +) And items in the navigation menu that are only meant for wholesale clients. I asked a similar question here (https://www.odoo.com/forum/Help-1/question/How-To-Remove-Pricing-For-Not-Logged-In-Users-on-E-commerceWebsite-for-Distributor-Business-to-Business-Sales-52924), but still do not fully understand how the Qweb markup works. I'm looking to implement something similar to Denise. Product catalog (no prices or ecommerce functionality) for the casual visitor, while allowing our distributors to sign in and place orders using the shopping cart and changing the button add to cart to add to quote. I've found a module that seems to be under development for v8 here also: https://github.com/maxmumford/website_b2b i'll post back here with what I find in regards to how it is implemented.

Is this option still viable in Odoo 10? I've looked and can't find the same structure.

Hi Scott,

This should still be fundamentally the same process in version 10.0, although the views may have been reshuffled a little.

What exactly would you like to achieve in v10.0?

How can I hide the product page itself, because it still showing in google search as follows www.yourdomain.com/shop/product/product_name

I tried to use this domain filter [('url','not like','%/shop/product/?\W+%')] but it didn't work.. can you help me please to write the right domain filter

still works in 2023 for v16 :P

hello,

I used the menu hiding option which works great, but I do not want to edit the code or HTML. Is there not a way to use record rules to hide a page, like " [('page','not like','%/shop%')] group: public.... object: Page..... for example? (i have no idea if this works or not)

let me know, thanks!

Best Answer

Frédéric Gilson (fgi)On 4/30/14, 8:56 PM Answered the exact way through UI. But this will not be the correct way always. We can do that in our code like in the shop controller just check the thing whether has a user and only render the e-commerce template if request has a user.

eg:

@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)
    def shop(self, page=0, category=None, search='', ppg=False, **post):
      if request.uid:
#only render the template with other operations
return request.website.render("website_sale.products", values)
else:
return request.website.render("website_sale.error_page", {})




Avatar
Discard

I get the following error (might be m< lack of knowledge on how to inherit controllers):

NameError: name 'values' is not defined

Also, is the "public" user also a valid user and will be able to see the products and product pages?

Best Answer

can you share screenshots or video for this 


Avatar
Discard
Best Answer

@Frédéric Gilson,

Excellent solution. Does not need any module installation.

Thank you

Avatar
Discard
Best Answer

hi,

I followed the steps, and the user is no longer able to access to mysite.com/shop.

but... the public user can still access to my shop store via google (in google I see all the items that I have on the shop) and access to "add to cart" button.

To avoid this issue:

You need to install the "Warning Messages and Alerts" module; then you need to go to Sales -> Customers -> "Public User" -> Warnings -> Warning on the Sales Order -> Blocking Message.

Regards

Avatar
Discard
Best Answer

Frédéric Gilson (fgi)   - Brilliant Answer, works every time.

Avatar
Discard
Best Answer

Hi Frédéric,

I followed your steps in the HTML editor but even users that are not signed in can still see the Webshop in the menu (although the page gets blank when they click the menu item). Do you have any idea why? I tried to delete the browser history and it didn't help.

/Johanna

Avatar
Discard
Best Answer

Hello Frédéric.

I have followed your steps, but I don't find "Rule definition" to enter that piece of code, instead I can see "Domain".

Do I have to enter it in the "Domain" field?

Thanks.

Avatar
Discard
Best Answer

@Luke as I cannot add a new comment or answer I'll answer to you by editing my previous answer. As far as I understand from you my wish cannot be accomplished in the SAAS version so I will not start a new post for now. In case I plan to install on VPS instead I might get back to you. Thx for your help so far.

----------------------------

 

I would like to use the webshop as a catalogue only to users who are not logged in showing public price. However only invited users (retailers) are allowed to logon and able to order at the (wholesale) pricelist assigned to them.

Therefore I'm looking for a way to only remove the "add to cart" button from the product overview and product page. Tried looking for a submit tag in the html where I could put groups="base.group_user,base.group_portal to see if this would only hide the cart button but couldn't find a spot to put it.

Anybody any suggestions?

Best regards,

 

Denise

Avatar
Discard

@Denise, It seems that the comments are treating my code snippet as actual HTML instead of escaping it. Please create a new question thread in the forum with your question above and I will create an answer for it so as to conform with the guidelines of the forum properly.

@Luke, no worries as I could still understand the post above. However I'm not on a local install and exploring ODOO SAAS for a couple of years now as I feel an easy to implement solution would be the way to go forward. ODOO 9 seems another great improvement again.