Files
odoo_source/addons/test_xlsx_export/models.py
T
Andrea Grazioso (agr-odoo) 01077a32a6 [FIX] web: fix float value representation in export
- Create a product with:
  Cost: 60.80
  Quantity On Hand: 999.0
- Go to Inventory / Reporting / Inventory Valuation
- Click on export all (little button next to "Inventory at date")

The field "Total value" have too many decimals: 60739.2000000004

This occur because of the multiplication: it yield the correct value
(60739.2), but every rounding attempt done, even in the ORM, will
mess up the representation

https://github.com/odoo/odoo/blob/042298f8c949fba470eda6ad90f94c95ca291030/odoo/fields.py#L1333

opw-2438384

closes odoo/odoo#67558

X-original-commit: 67cf82962688360cfe25c6b2118a7dbd17a6ee95
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2021-03-15 08:43:53 +00:00

37 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class NewModel(models.Model):
_name = 'export.integer'
_description = 'Export: Integer'
value = fields.Integer(default=4)
def name_get(self):
return [(record.id, "%s:%s" % (self._name, record.value)) for record in self]
class GroupOperator(models.Model):
_name = 'export.group_operator'
_description = 'Export Group Operator'
int_sum = fields.Integer(group_operator='sum')
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')
many2one = fields.Many2one('export.integer')
one2many = fields.One2many('export.group_operator.one2many', 'parent_id')
class GroupOperatorO2M(models.Model):
_name = 'export.group_operator.one2many'
_description = 'Export Group Operator One2Many'
parent_id = fields.Many2one('export.group_operator')
value = fields.Integer()