From 1f10ef8055f6c661fc6407a8ce4593dfc30452b4 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Mon, 28 Nov 2016 11:26:54 +0100 Subject: [PATCH] [FIX] website_sale: fix amount format display Before this commit, amount updated from ajax request don't respect currency format. Eg: 1.200,000 => 1200.00 Now we use the grouping/thousand separator/decimal separator from l10n, and if class decimal_precision is defined in dom, we use it. (format=0.001) This commits closes: #11553 This commits is related to #1103 --- addons/website_sale/data/demo.xml | 2 +- .../static/src/js/website_sale.js | 47 +++++++++++++++++-- addons/website_sale/views/templates.xml | 6 +-- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/addons/website_sale/data/demo.xml b/addons/website_sale/data/demo.xml index 9beb8052a4c..d4fda5243ca 100644 --- a/addons/website_sale/data/demo.xml +++ b/addons/website_sale/data/demo.xml @@ -174,7 +174,7 @@ Capacity: 16GB Connectivity: Wifi Beautiful 7.9-inch display -Over 375,000 apps3 +Over 375,000 apps Ultrafast wireless iOS7 diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 565e82b458b..033b8c3885e 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -73,13 +73,13 @@ $('.oe_website_sale').each(function () { 'line_id': line_id}) .then(function (res) { //basic case - $dom.find('span.oe_currency_value').last().text(res[product_id].toFixed(2)); + $dom.find('span.oe_currency_value').last().text(price_to_str(res[product_id])); $dom.find('.text-danger').toggle(res[product_id] default_price/100)); //optional case $dom_optional.each(function(){ var id = $(this).find('span[data-product-id]').data('product-id'); var price = parseFloat($(this).find(".text-danger > span.oe_currency_value").text()); - $(this).find("span.oe_currency_value").last().text(res[id].toFixed(2)); + $(this).find("span.oe_currency_value").last().text(price_to_str(res[id])); $(this).find('.text-danger').toggle(res[id]price/100)); }); openerp.jsonRpc("/shop/cart/update_json", 'call', { @@ -145,10 +145,47 @@ $('.oe_website_sale').each(function () { $('.css_attribute_color:has(input:checked)').addClass("active"); }); + // Copy from core.js that is not available in front end. + function intersperse(str, indices, separator) { + separator = separator || ''; + var result = [], last = str.length; + + for(var i=0; i - +