Comment 4 for bug 723662

Revision history for this message
sraps (Alistek) (erpsraps) wrote :

The error happens with other reporting engines than the ReportLab. For example Aeroo Reports are using floating point value directly by using built in Python's __str__ method, which were overloaded by OpenERP server.

The method "__str__", when the float value is "0.00" still returns floating point value, which is against Python conventions:

http://docs.python.org/reference/datamodel.html#object.__str__
Quote> The return value must be a string object.

This is the code from the "report_sxw.py" file, line #77:

class _float_format(float, _format):
    def __init__(self,value):
        super(_float_format, self).__init__()
        self.val = value

    def __str__(self):
        digits = 2
        if hasattr(self,'_field') and getattr(self._field, 'digits', None):
            digits = self._field.digits[1]
        if hasattr(self, 'lang_obj'):
            return self.lang_obj.format('%.' + str(digits) + 'f', self.name, True)
        return self.val

Pay attention to the last line, which evidently does not return string, as it should have.