From 0e9d7318fc2c47a1b3fe495bf12f90c968e36ea9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 21 Oct 2011 14:22:56 +0200 Subject: [PATCH] [FIX] float formatting in form view should take digits/@digits in account lp bug: https://launchpad.net/bugs/879346 fixed bzr revid: xmo@openerp.com-20111021122256-ld3gm8u3yt4kdn71 --- addons/web/static/src/js/view_form.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index f8168d21466..8736f2d69e3 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1233,6 +1233,19 @@ openerp.web.form.FieldUrl = openerp.web.form.FieldChar.extend({ }); openerp.web.form.FieldFloat = openerp.web.form.FieldChar.extend({ + init: function (view, node) { + this._super(view, node); + if (node.attrs.digits) { + this.parse_digits(node.attrs.digits); + } else { + this.digits = view.fields_view.fields[node.attrs.name].digits; + } + }, + parse_digits: function (digits_attr) { + // could use a Python parser instead. + var match = /^\s*[\(\[](\d+),\s*(\d+)/.exec(digits_attr); + return [parseInt(match[1], 10), parseInt(match[2], 10)]; + }, set_value: function(value) { if (value === false || value === undefined) { // As in GTK client, floats default to 0