diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js
index d4896276b90..845014926b3 100644
--- a/addons/web/static/src/js/views/list/list_renderer.js
+++ b/addons/web/static/src/js/views/list/list_renderer.js
@@ -405,6 +405,7 @@ var ListRenderer = BasicRenderer.extend({
data: record.data,
escape: true,
isPassword: 'password' in node.attrs,
+ digits: node.attrs.digits && JSON.parse(node.attrs.digits),
});
this._handleAttributes($td, node);
var title = field.type !== 'boolean' ? formattedValue : '';
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 81de376aef0..55cec265329 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -6670,6 +6670,19 @@ QUnit.module('Views', {
list.destroy();
});
+ QUnit.test('float field render with digits attribute on listview', async function (assert) {
+ assert.expect(1);
+
+ var list = await createView({
+ View: ListView,
+ model: 'foo',
+ data: this.data,
+ arch: '',
+ });
+
+ assert.strictEqual(list.$('td.o_list_number:eq(0)').text(), "0.400000", "should contain 6 digits decimal precision");
+ list.destroy();
+ });
// TODO: write test on:
// - default_get with a field not in view
});
diff --git a/odoo/addons/base/models/res_currency.py b/odoo/addons/base/models/res_currency.py
index a7f25a2df0b..86099e3faee 100644
--- a/odoo/addons/base/models/res_currency.py
+++ b/odoo/addons/base/models/res_currency.py
@@ -28,7 +28,7 @@ class Currency(models.Model):
# Note: 'code' column was removed as of v6.0, the 'name' should now hold the ISO code.
name = fields.Char(string='Currency', size=3, required=True, help="Currency Code (ISO 4217)")
symbol = fields.Char(help="Currency sign, to be used when printing amounts.", required=True)
- rate = fields.Float(compute='_compute_current_rate', string='Current Rate', digits=(12, 6),
+ rate = fields.Float(compute='_compute_current_rate', string='Current Rate', digits=0,
help='The rate of the currency to the currency of rate 1.')
rate_ids = fields.One2many('res.currency.rate', 'currency_id', string='Rates')
rounding = fields.Float(string='Rounding Factor', digits=(12, 6), default=0.01)
@@ -235,7 +235,7 @@ class CurrencyRate(models.Model):
name = fields.Date(string='Date', required=True, index=True,
default=lambda self: fields.Date.today())
- rate = fields.Float(digits=(12, 6), default=1.0, help='The rate of the currency to the currency of rate 1')
+ rate = fields.Float(digits=0, default=1.0, help='The rate of the currency to the currency of rate 1')
currency_id = fields.Many2one('res.currency', string='Currency', readonly=True)
company_id = fields.Many2one('res.company', string='Company',
default=lambda self: self.env.company)
diff --git a/odoo/addons/base/tests/test_float.py b/odoo/addons/base/tests/test_float.py
index 4dbf1f5f139..7ece1b0b8ce 100644
--- a/odoo/addons/base/tests/test_float.py
+++ b/odoo/addons/base/tests/test_float.py
@@ -172,8 +172,7 @@ class TestFloatPrecision(TransactionCase):
self.assertEqual(rate.rate, expected,
'Roundtrip error: got %s back from db, expected %s' % (rate, expected))
- # res.currency.rate uses 6 digits of precision by default
- try_roundtrip(2.6748955, 2.674896, '2000-01-01')
+ # res.currency.rate no more uses 6 digits of precision by default, it now uses whatever precision it gets
try_roundtrip(10000.999999, 10000.999999, '2000-01-03')
#TODO re-enable those tests when tests are made on dedicated models
diff --git a/odoo/addons/base/views/res_currency_views.xml b/odoo/addons/base/views/res_currency_views.xml
index 52bbcb71cb3..bb7c987160e 100644
--- a/odoo/addons/base/views/res_currency_views.xml
+++ b/odoo/addons/base/views/res_currency_views.xml
@@ -17,7 +17,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
@@ -75,7 +75,7 @@
-
+
@@ -102,7 +102,7 @@
@@ -125,7 +125,7 @@
-
+