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.

0

How can I change website_sale template.xml without change origin file

By
chen rong
on 4/24/15, 11:05 PM 1,106 views


<template id="product_price">

<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price mt16">

<h4 class="oe_price_h4 css_editable_mode_hidden">

<span class="text-danger oe_default_price" style="text-decoration: line-through; white-space: nowrap;"

t-field="product.lst_price"

t-field-options='{

"widget": "monetary",

"from_currency": "product.company_id.currency_id",

"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"

}'/>

<b class="oe_price" style="white-space: nowrap;"

t-field="product.user_price"

t-field-options='{

"widget": "monetary",

"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"

}'/>

<span itemprop="price" style="display:none;" t-esc="product.user_price"/>

<span itemprop="priceCurrency" style="display:none;" t-esc="user_id.partner_id.property_product_pricelist.currency_id.name"/>

</h4>

<h4 class="css_editable_mode_display" style="display: none;">

<span t-field="product.lst_price"

t-field-options='{

"widget": "monetary",

"display_currency": "website.pricelist_id.currency_id"

}'/>

</h4>

<h4 class="hidden oe_not_available bg-warning">Product not available</h4>

</div>

</template>

I want change product.price to product.user_price 

thanks ,solved

chen rong
on 4/25/15, 5:31 AM
0
SonnyV
On 4/27/15, 6:01 AM

Hello

Create a new module in a folder on the server that is listed in your odoo-config's addons path.

to create a new module use ./odoo.py scaffold 'My Module Name' /path/to/addons/path

your new module has now been created.

In the folder 'view' or 'views' you'll find an xml called views.xml. In here you can create a new template which would inherit the current template. Then you write an xpath either to the element itself and replace it. Or you write an xpath to the top element and copy the entire code. I opted for the latter. So my example will just override the entire template:


<!--/shop/product show price incl VAT-->

<template id="product_price_inherit" inherit_id="website_sale.product_price">

<xpath expr="//div[@itemprop='offers']" position="replace">

<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price mt16">

<h4 class="oe_price_h4 css_editable_mode_hidden">

<span class="text-danger oe_default_price" style="text-decoration: line-through; white-space: nowrap;"

t-field="product.price_incl"

t-field-options='{

"widget": "monetary",

"from_currency": "product.company_id.currency_id",

"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"

}'/>

<b class="oe_price" style="white-space: nowrap;"

t-field="product.user.price"

t-field-options='{

"widget": "monetary",

"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"

}'/>

<br/>

<span style="font-size:70%;color:#bdbdbd;">

(<span class="oe_price" style="white-space: nowrap;"

t-field="product.price"

t-field-options='{

"widget": "monetary",

"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"

}'/>

excl. BTW)</span>

<span itemprop="price" style="display:none;" t-esc="product.price_incl"/>

<span itemprop="priceCurrency" style="display:none;" t-esc="user_id.partner_id.property_product_pricelist.currency_id.name"/>

</h4>

<h4 class="css_editable_mode_display" style="display: none;">

<span t-field="product.price_incl"

t-field-options='{

"widget": "monetary",

"display_currency": "website.pricelist_id.currency_id"

}'/>

</h4>

<h4 class="hidden oe_not_available bg-warning">Product not available</h4>

</div>

</xpath>

</template>


Please notice that I have changed some variables in my code (to price_incl) so just copy pasting won't work. The best method to copy this is to copy the <template> and <xpath> tag, manually close them and paste the code of the current product price template starting with the &lt;div itemprop="offers" ..> tag and ending with the coresponding end-tag


Regards

0
Hengky Zhang
On 4/24/15, 11:37 PM

you need to inherit the xml using xpath

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

1 follower(s)

Stats

Asked: 4/24/15, 11:05 PM
Seen: 1106 times
Last updated: 4/27/15, 6:01 AM