summaryrefslogtreecommitdiff
path: root/addons/test_xlsx_export
diff options
context:
space:
mode:
Diffstat (limited to 'addons/test_xlsx_export')
-rw-r--r--addons/test_xlsx_export/models.py2
-rw-r--r--addons/test_xlsx_export/tests/test_export.py29
2 files changed, 31 insertions, 0 deletions
diff --git a/addons/test_xlsx_export/models.py b/addons/test_xlsx_export/models.py
index 99d96ba63cb..830917c0664 100644
--- a/addons/test_xlsx_export/models.py
+++ b/addons/test_xlsx_export/models.py
@@ -20,6 +20,8 @@ class GroupOperator(models.Model):
int_max = fields.Integer(group_operator='max')
float_min = fields.Float(group_operator='min')
float_avg = fields.Float(group_operator='avg')
+ float_monetary = fields.Monetary(currency_field='currency_id',group_operator='sum')
+ currency_id = fields.Many2one('res.currency')
date_max = fields.Date(group_operator='max')
bool_and = fields.Boolean(group_operator='bool_and')
bool_or = fields.Boolean(group_operator='bool_or')
diff --git a/addons/test_xlsx_export/tests/test_export.py b/addons/test_xlsx_export/tests/test_export.py
index 22b759e7940..0ee3a05d087 100644
--- a/addons/test_xlsx_export/tests/test_export.py
+++ b/addons/test_xlsx_export/tests/test_export.py
@@ -50,6 +50,7 @@ class XlsxCreatorCase(common.HttpCase):
params['fields'] = [{
'name': self.model._fields[f].name,
'label': self.model._fields[f].string,
+ 'type': self.model._fields[f].type,
} for f in fields]
with patch.object(ExportXlsxWriter, 'write', self._mock_write):
@@ -340,3 +341,31 @@ class TestGroupedExport(XlsxCreatorCase):
[' Undefined (1)' ,''],
['10' ,''],
])
+
+ def test_float_representation(self):
+ currency = self.env['res.currency'].create({
+ 'name': "bottlecap",
+ 'symbol': "b",
+ 'rounding': 0.001,
+ 'decimal_places': 3,
+ })
+
+ values = [
+ {'int_sum': 1, 'currency_id': currency.id, 'float_monetary': 60739.2000000004},
+ {'int_sum': 2, 'currency_id': currency.id, 'float_monetary': 2.0},
+ {'int_sum': 3, 'currency_id': currency.id, 'float_monetary': 999.9995999},
+ ]
+ export = self.export(values, fields=['int_sum', 'float_monetary'], params={'groupby': ['int_sum', 'float_monetary']})
+
+ self.assertExportEqual(export, [
+ ['Int Sum', 'Float Monetary'],
+ ['1 (1)','60739.200'],
+ [' 60739.2 (1)','60739.200'],
+ ['1','60739.2'],
+ ['2 (1)','2.000'],
+ [' 2.0 (1)','2.000'],
+ ['2','2.0'],
+ ['3 (1)','1000.000'],
+ [' 1000.0 (1)','1000.000'],
+ ['3','1000.0'],
+ ])