This question has been flagged

I'm interested in setting up the Odoo website/e-commerce system for various distributors' websites. This would require me to allow the products to be displayed with general information (ie. product pictures, description,etc.) without pricing to the general public (ie. those that are not logged in). I would then need to be able to provide a login for pre-approved accounts to allow wholesalers to login and see their own pricing according to their pricelist rules and allow them to add to cart/quote which would trigger a RFQ or sales order in Odoo v8.

Unfortunately there is not much information regarding the website/e-commerce module available currently due to the fact Odoo v8 is still in alpha.

I believe this would be extremely useful for distributors to be able to display their products without pricing unless a pre-approved account is setup for them to login. It is possible to do with Magento with various extensions such as the B2B Extension for Magento found here:

https://github.com/sitewards/B2BProfessional

or by editing the local.xml file in various theme packages in Magento by using the <customer_logged_in> and <customer_logged_out> tags to provide conditional logic based on those two situations.

I have been looking for a way to either connect Magento (CE 1.8/1.9) to Odoo (v8) by means of a connector (currently there is nothing available) or be able implement this with the current Odoo E-commerce/Website module (preferred). If anyone has any insight on this please comment below as I would appreciate any input on this.

Avatar
Discard
Best Answer

You have to change the view that is responsible for displaying the price. To do that:

  • go to: Settings -> Technical -> User Interface -> Views (Technical Settings need to be enabled for your user)
  • Search for the "product_price" view (it has QWeb as view type)
  • add t-if="not user_id.partner_id.name == 'Public user'" to the first occuring div
    Result: 
    <div t-if="not user_id.partner_id.name == 'Public user'" itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price mt16">

​This stops displaying prices on the product page.

To not show prices for users who are not logged in on the page with the overview of the products:

  • open the start page of the shop
  • Go to the HTML-Editor via Customize
  • ​select the "Product item" view
  • again add t-if="not user_id.partner_id.name == 'Public user'" to the following element:
    <div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price" ...
Avatar
Discard
Author

@Martin Apitz, Thank you for the detailed explanation, i'll try your suggestions and post back with what I find.

Author

@Martin Aptitz, Thank you for your tutorial. This works great for my needs and can be applied to multiple other scenarios requiring hiding elements of the website from public view. This has been a huge help in creating a theme module that is suitable for B2B sales through the website frontend (ie. Distributor > Wholesaler). I have noticed in the Product Item view however that I cannot add two t-if's to a single element (ie. the

with the t-if="not user_id.partner_id.name == 'Public user'", however i'm curious as to whether this is best practice for this type of situation (ie. when multiple t-if statements need to be applied to a single element), or whether there is a way to add multiple t-if's to a single element.
Author

@Martin Apitz, Thanks for your reply, unfortunately it seems to have only come through by email so i'm posting it back here for the benefit of others in the forum: Hi Luke, you can have more then one condition in one t-if statement by combining them with "and". Like so: t-if="[first condition] and [second condition]" thanks for all your help with this question.

Best Answer

Hello guys,

What is the best solution for this on Odoo 12 or 13?

I believe some of us have the same problem, that is, to hide the prices for not logged in users.

I'm curious to know if the Odoo evolved in a way that this is easier to implement nowadays.


Regards,

Paulo

Avatar
Discard
Best Answer

You can do this in standard in Odoo. You need to include a condition in the QWeb/HTML. You can access this directly in the Odoo Website builder in Customize > HTML Editor.

I'm not a specialist in QWeb syntax, some documentation is available in the following link and more will come in June. https://doc.openerp.com/trunk/web/qweb/
My guess is that you need to insert a t-if= attribute in the HTML tag of the amount you only want to display to logged in users. There are plenty of examples of this in the default site.

Side note: There is no connector between Magento and Odoo v8 simply because Odoo v8 has not been released yet... However there are a whole bunch of them for OpenERP v7 so chances are that some of them get migrated to v8. But anyway, as you said, Odoo Website is the preferred solution because natively integrated.

Avatar
Discard
Best Answer

Hello,

I was able to remove the price form the overview of the products for not logged in users, but can I do it for all users?

I want to remove the price on the "Product item" view in the HTLM-Editor for all users. Is this possible?

Thank you, in advance!

Avatar
Discard
Best Answer

I made was Martin Apitz proposed in the first step. For the second part , I edit the Product view (Template ID: website_sale.product) adding the t-if="not... in line 46 and at the end of this form a new "div" so not logged-in users see a button "Sign in to see your prices".

Avatar
Discard

Sorry, I cannot post it properly and every time when I try to change it, it get worst.
<div >
<a t-if=" user_id.partner_id.name == 'Public user'" role="button" t-attf-href="/web/login" class="#{_link_class}, btn btn-primary btn-lg mt16" href="#" > &amp;nbsp;&amp;nbsp;&amp;nbsp;Sign in to see your prices</a>
</div>

Author Best Answer

@Francisco, what i'd recommend is that you inherit and replace the Add to Cart button with a link to your login page. Here's an example of inheriting the default add to cart button:
 

<template id="product_add_to_cart_Custom" inherit_id="website_sale.product" name="Add To Quote - Logged In" customize_show="True">
    <xpath expr="//a[@id='add_to_cart']" position="replace">
        <a t-if="not user_id.partner_id.name == 'Public user'" id="add_to_cart" class="btn btn-primary btn-lg mt8 js_check_product a-submit" href="#"><i class="fa fa-angle-double-right"></i>&amp;nbsp;&amp;nbsp;&amp;nbsp;Add to Quotation</a>
    </xpath>
</template>

 You could then use conditional t-if statements to replace the add to cart button in the example above with your login-for-price button (just link to yourdomain.com/web/login), and the have another conditional t-if statement to display a normal add to cart or 'add to quote' button for users that are logged in.

I will be creating a community module to achieve this type of functionality in the near future to simplify things for B2B users like yourself here:

http://www.github.com/odoocommunitywidgets

Please feel free to post back if you run into any issues or have any questions.

Avatar
Discard
Best Answer

Hi @luke, I'm interested in this kind of functionality too, by following Martin Apitz instructions,

1. I got to hide the price on the single product page, however I'd like to change the Add to Cart button to someting like the sitewards/B2BProfessional example "Please Login for Price Information" and the link would take the visitor to a sing up form.

2. Changing the Product Item View from the HTML Editor did not work for me after saving changes on that file resulting:  <div  itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price" t-if="[product.product_variant_ids] and [not user_id.partner_id.name == 'Public user']">   I'm guessing that this should hide prices in the main shop page ej. http://myurl.com/shop , is this right? 

Regards,

 

Avatar
Discard
Author

@Francisco, what i'd recommend is that you inherit and replace the Add to Cart button with a link to your login page. Here's an example of inheriting the default add to cart button: <xpath expr="//a[@id='add_to_cart']" position="replace"> &nbsp;&nbsp;&nbsp;Add to Quotation You could then use conditional t-if statements to replace the add to cart button in the example above with your login-for-price button (just link to yourdomain.com/web/login), and the have another conditional t-if statement to display a normal add to cart or 'add to quote' button for users that are logged in. I will be creating a community module to achieve this type of functionality in the near future to simplify things for B2B users like yourself here: http://www.github.com/odoocommunitywidgets Please feel free to post back if you run into any issues or have any questions.

Author

@Francisco, That last comment did not display the code correctly. I'll add it as an answer instead so that you can see the code snippet.

Hey Luke, thanks for your kind answer, I'll be looking forward for that B2B module you mentioned, Regards,

Best Answer

Thank you everyone for all the answers in this post.

Luke:
I've gotten the first 2 answers working (hide pricing), but I'm having difficulty figuring out "inherit and replace the Add to Cart button " answer.

Where does the template snippet go?
Where do I put the "t-if statements to replace the add to cart button"?

Any help would be much appreciated :)

Thanks


 

Avatar
Discard
Author

Here's a link to my answer here:
https://github.com/OdooCommunityExamples/B2B_Add_To_Cart_Example

I've put together an incredibly basic module with only the functionality needed for what you have asked in this question.

I have added the view change (that snippet) into an xml file in a subdirectory called 'views' to organise it properly. Fundamentally you just need an __init__.py file, an __openerp__.py file with your dependencies (in this case website_sale, etc.), and your view definition (in this case /views/B2B_Add_To_Cart.xml).

Inside this XML file you just need to place your tags nested inside the opening and closing and tags. Remember that you are working with XHTML/XML, and therefore opening and closing tags must be properly nested or you will run into problems.

In regards to the t-if statements, you are simply stating in Qweb that it should use this tag only if the user id in the database in the database (not user_id.partner_id.name) is equal to (==) the name 'Public user'.

Therefore whatever nested tags are inside that tag there, they will only be displayed to users if there user id is not 'Public user'.

Author

@Tiberius, It looks like Odoo's commenting system has stripped out the tags in this comment. Please refer to the following gist for my comment: https://gist.github.com/lukebranch/0ca9665175816d0c9f3f

Thank you Luke!

Best Answer

Hi All,

I’v got rid of the prices on the first to pages of the webshop by following Martin's instructions regarding the product-item and product price views. However, prices re-appear in the shopping cart page so after products have been added to cart.

I guess that there is an additional view that needs to be adapted?

Kind regards

Bob


 

Avatar
Discard

bonjour,

avez-vous réussi à supprimer l'affichage des prix dans le panier quand personne n'est connecté?

Best Answer

How can I also do this for the categoy pages?

Avatar
Discard
Best Answer

If it's hard for you to find small business payroll software sites, maybe I can help.


http://guidesforpayroll.com/

Avatar
Discard