diff --git a/addons/account/static/src/js/account_reconciliation_widgets.js b/addons/account/static/src/js/account_reconciliation_widgets.js index 453bd4149a5..a2b0f66d9b7 100644 --- a/addons/account/static/src/js/account_reconciliation_widgets.js +++ b/addons/account/static/src/js/account_reconciliation_widgets.js @@ -763,7 +763,9 @@ var abstractReconciliationLine = Widget.extend({ else if (preset_line.amount_type === "percentage") { self.amount_field.set_value(0); self.updateBalance(); - self.amount_field.set_value(-1 * self.get("balance") * preset_line.amount / 100); + var currency_dict = session.get_currency(self.get("currency_id")); + var preset_amount = utils.round_currency(currency_dict, -1 * self.get("balance") * preset_line.amount / 100); + self.amount_field.set_value(preset_amount); } } }, diff --git a/addons/web/static/src/js/framework/utils.js b/addons/web/static/src/js/framework/utils.js index e19246823c5..0dc66c6817f 100644 --- a/addons/web/static/src/js/framework/utils.js +++ b/addons/web/static/src/js/framework/utils.js @@ -350,6 +350,15 @@ function round_decimals (value, decimals) { return round_precision(value, Math.pow(10,-decimals)); } +/* Rounds a value according to a currency's digits + * @param {dict} The dict containing the currency's info, usually retrieved with session.get_currency + * @param {Number} The value to be rounded + */ +function round_currency(currency_dict, value) { + var digits = currency_dict && currency_dict.digits[1] || 4; + return round_decimals(value, digits); +} + function float_is_zero (value, decimals) { var epsilon = Math.pow(10, -decimals); return Math.abs(round_precision(value, epsilon)) < epsilon; @@ -516,6 +525,7 @@ return { human_number: human_number, round_precision: round_precision, round_decimals: round_decimals, + round_currency: round_currency, float_is_zero: float_is_zero, confine: confine, assert: assert,