Odoo Help

Welcome!

This community 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.

3

How To Remove Pricing For (Not Logged In) Users on E-commerce/Website for Distributor Business to Business Sales

By
Luke Branch
on 5/24/14, 1:20 AM 18,386 views

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.

8
Martin Apitz
On 9/10/14, 9:37 AM

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

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

Luke Branch
on 9/12/14, 9:27 PM

@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.
Luke Branch
on 9/13/14, 12:06 AM

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

Luke Branch
on 9/15/14, 2:32 AM
1

Fabrice Henrion (fhe)

--Fabrice Henrion (fhe)--
5823
| 7 7 8
San Francisco, United States
--Fabrice Henrion (fhe)--

Director Odoo USA

Fabrice Henrion (fhe)
On 5/24/14, 7:32 PM

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.

0
Tim
On 3/3/16, 4:18 AM

How can I also do this for the categoy pages?

0
Bob Maes
On 3/2/16, 8:54 AM

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


 

0
Tiberius Onerous
On 1/23/15, 12:13 PM

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


 

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

Luke Branch
on 1/23/15, 10:01 PM

@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

Luke Branch
on 1/23/15, 10:04 PM

Thank you Luke!

Tiberius Onerous
on 1/26/15, 2:01 PM
0
Francisco Milland
On 12/11/14, 8:47 PM

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,

 

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

Luke Branch
on 12/11/14, 10:54 PM

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

Luke Branch
on 12/11/14, 10:55 PM

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

Francisco Milland
on 12/12/14, 9:35 PM
0

Luke Branch

--Luke Branch--
1531
| 6 7 8
Mui Wo, Lantau, Hong Kong
--Luke Branch--

...

Luke Branch
On 5/26/14, 12:26 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

8 follower(s)

Stats

Asked: 5/24/14, 1:20 AM
Seen: 18386 times
Last updated: 11/13/16, 12:16 PM