Odoo Help

2

How to restrict the access to the eCommerce menu?

By
Frédéric Gilson (fgi)
on 4/30/14, 10:28 AM 10,960 views

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

9
  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.

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.

Luke Branch
on 7/11/14, 9:40 PM

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

Scott Hart
on 3/8/17, 7:01 AM

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?

Luke Branch
on 3/9/17, 3:20 AM

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

youta
on 3/11/17, 5:16 AM
1

Hilar

--Hilar--
1914
| 5 3 8
Malappuram, India
--Hilar--
  Blog:-
        https://hilarlive.wordpress.com/
  StackOverflow:
        http://stackoverflow.com/users/7561347/burmese-pythis

Hilar
On 3/13/17, 6:35 AM

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", {})




0
Johanna Löfvenberg
On 3/30/17, 8:28 AM

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

0
Adam Moonen
On 9/9/15, 7:43 PM

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

0
Jonathan Hurtado
On 6/17/15, 4:25 PM

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

0
Andrés Méndez
On 3/10/15, 6:54 PM

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.

-1

@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

@Denis, I suggest you take a look at this post: 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 I've used the attribute/value t-if="not user_id.partner_id.name == 'Public user'" for hiding XHTML tags from the casual (ie. public user), although i think this could be modified to only show the cart button for portal users as well. Either way i'd recommend inheriting the add to cart code from website_sale.product and then modify it to suit your needs. Here's what I did: <xpath expr="//a[@id='add_to_cart']" position="replace"> &nbsp;&nbsp;&nbsp;Add to Quotation If you're on a local install you'd just need to create a very basic module to use this view. I'll be creating a module for this type of B2B functionality for the website/frontend soon, however if you need any tips on how to implement this as a custom module in the meantime please feel free to comment back and i'll walk you through it.

Luke Branch
on 11/19/14, 12:15 AM

@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 Branch
on 11/19/14, 12:17 AM

@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.

Denise van der Linden-Morris
on 8/17/15, 8:56 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

12 follower(s)

Stats

Asked: 4/30/14, 10:28 AM
Seen: 10960 times
Last updated: 3/30/17, 8:31 AM