Odoo Help

4
9
Martin Apitz
On 14-9-10 上午9:37

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 14-9-12 下午9:27

@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 14-9-13 上午12:06

@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 14-9-15 上午2:32
1
Avatar

Fabrice Henrion (fhe)

--Fabrice Henrion (fhe)--
6553
| 7 7 9
San Francisco, 美国
--Fabrice Henrion (fhe)--

Director Odoo Americas

Fabrice Henrion (fhe)
On 14-5-24 下午7:32

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
Jaycee Williams
On 18-7-17 下午4:57

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


http://guidesforpayroll.com/

0
Avatar

Luke Branch

--Luke Branch--
1599
| 7 8 8
Mui Wo, Lantau, 香港特别行政区
--Luke Branch--

...

Luke Branch
On 14-5-26 上午12:26

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

-1
Francisco Milland
On 14-12-11 下午8:47

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 14-12-11 下午10:54

@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 14-12-11 下午10:55

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

Francisco Milland
on 14-12-12 下午9:35
-1
Tiberius Onerous
On 15-1-23 下午12:13

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 15-1-23 下午10:01

@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 15-1-23 下午10:04

Thank you Luke!

Tiberius Onerous
on 15-1-26 下午2:01
-1
Bob Maes
On 16-3-2 上午8:54

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


 

-1
Tim
On 16-3-3 上午4:18

How can I also do this for the categoy pages?

About This Community

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

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

8 follower(s)

Stats

Asked: 14-5-24 上午1:20
Seen: 25233 times
Last updated: 18-9-30 上午10:05