[FIX] website_sale: format amount according to currency client side

This commit closes #1103, closes #11553
This commit is contained in:
Jeremy Kersten
2016-11-29 16:40:15 +01:00
parent a5f186c158
commit fee6015964
3 changed files with 12 additions and 7 deletions
@@ -29,9 +29,7 @@ var TranslationDataBase = Class.extend(/** @lends instance.TranslationDataBase#
});
if (translation_bundle.lang_parameters) {
this.parameters = translation_bundle.lang_parameters;
if (typeof(py) !== "undefined") {
this.parameters.grouping = py.eval(this.parameters.grouping);
}
this.parameters.grouping = JSON.parse(this.parameters.grouping);
}
},
add_module_translation: function(mod) {
@@ -53,6 +53,7 @@ odoo.define('website_sale.website_sale', function (require) {
var ajax = require('web.ajax');
var core = require('web.core');
var utils = require('web.utils');
var _t = core._t;
var base = require('web_editor.base');
@@ -250,9 +251,15 @@ $('.oe_website_sale').each(function () {
});
function price_to_str(price) {
price = Math.round(price * 100) / 100;
var dec = Math.round((price % 1) * 100);
return price + (dec ? '' : '.0') + (dec%10 ? '' : '0');
var l10n = _t.database.parameters;
var precision = 2;
if ($(".decimal_precision").length) {
precision = parseInt($(".decimal_precision").first().data('precision'));
}
var formatted = _.str.sprintf('%.' + precision + 'f', price).split('.');
formatted[0] = utils.insert_thousand_seps(formatted[0]);
return formatted.join(l10n.decimal_point);
}
$(oe_website_sale).on('change', 'input.js_product_change', function () {
+1 -1
View File
@@ -434,7 +434,7 @@
<span itemprop="price" style="display:none;" t-esc="product.price"/>
<span itemprop="priceCurrency" style="display:none;" t-esc="website.currency_id.name"/>
</h4>
<h4 class="css_non_editable_mode_hidden">
<h4 class="css_non_editable_mode_hidden decimal_precision" t-att-data-precision="product.currency_id.decimal_places">
<span t-field="product.lst_price"
t-field-options='{
"widget": "monetary",