Odoo Help


How to respect the currency format in the shop even with products who have variants?

Pascal Tremblay
on 11/6/16, 12:28 PM 1,284 views

Hello there,

We are on Odoo 8.

I knew that I had a problem with the currency format in some case on my webshop. This morning, I noticed something...

For all products without variant, the price is well formatted (with a comma) :

But as soon as a product has some variants, the price is NOT well formatted (with a dot instead of the comma...) :

Would you have some ideas to format all my prices correctly in all cases?

Thanks for your comments


I suspect a problem in the file openerp/addons/website_sale/static/src/js/website_sale.js. I think the javascript is used when a product has some variants.

May be something in this code :

// change price when they are variants    
    $('form.js_add_cart_json label', oe_website_sale).on('mouseup touchend', function (ev) {       
        var $label = $(this);
        var $price = $label.parents("form:first").find(".oe_price .oe_currency_value");
        if (!$price.data("price")) {           
            $price.data("price", parseFloat($price.text()));
        var value = $price.data("price") + parseFloat($label.find(".badge span").text() || 0);
        var dec = value % 1;
        $price.html(value + (dec < 0.01 ? ".00" : (dec < 1 ? "0" : "") ));


Ţhe same thing arrives in the cart. When the customer change the quantity of an ordered item with the - or + buttons, the item price loses his comma for a dot :

Little up here. An idea?

Pascal Tremblay
on 12/10/16, 9:45 AM

Pascal Tremblay

--Pascal Tremblay--
| 5 3 7
Alma, Canada
--Pascal Tremblay--

Pascal Tremblay
On 12/11/16, 6:37 PM

With the help of Axel Mendoza, I managed it.

See this post : https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-override-the-price-to-str-function-of-website-sale-js-111804

This way, I have overriden the price_to_str() function and $(oe_website_sale).find(".oe_cart input.js_quantity").on("change", function () in the original website_sale.js file.

Thanks a lot Axel!

In the function $(oe_website_sale).find(".oe_cart input.js_quantity").on("change", function () :

I replaced this line


By this line

$dom.find('span.oe_currency_value').last().text(res[product_id].toFixed(2).toString().replace(/\./g, ','));

My new price_to_str() function is :

function price_to_str(price) {
                price = Math.round(price * 100) / 100;
                var price = price.toString().replace(/\./g, ',');
                return price

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.


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

1 follower(s)


Asked: 11/6/16, 12:28 PM
Seen: 1284 times
Last updated: 12/11/16, 6:38 PM