Unable to print 0.00 float value on a report

Bug #723662 reported by sraps (Alistek)
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

It is not possible to print float field with value "0.00" on a report, though the value eg. "1.00" would print just fine. Throws error that it is not possible to coerce value to the Unicode type.

This problem is present on whole OpenERP 6.x branch and at least on OpenERP v5.0.15.

The root of the problem lies in that there is a special field type class defined for automatic formatting purposes, and there is no "__repr__" method defined for the class.

File name: report_sxw.py
Class name: _float_format
Line number: ~82

Related branches

Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

I have attached the pdf with the value specified in bug specification. So please refer it and notify us.

For now I am closing this bug.

Thanks.

Changed in openobject-server:
status: New → Invalid
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Can you please check with the patch attached on https://bugs.launchpad.net/openobject-server/+bug/708461?
Thanks.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hello sraps, replacing this line http://bazaar.launchpad.net/~openerp/openobject-server/6.0/view/3350/bin/osv/orm.py#L219
with

                            if result_line[field_name] != None:

we solved the problem (with 0.0 float, 'set_value' was not called).

I don't know why this only happens with aeroo reports for now...
At least I did not find a way to reproduce it with rml reports yet

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.

Changed in openobject-server:
status: Invalid → New
Revision history for this message
Kinly (kinlyfordy4u) wrote :

+1 sraps (Alistek)

Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

I am confirming the issue for other report engines apart from rml of reportlab.

Thanks.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello,

Thanks for reporting.

It has been fixed in lp:~openerp-dev/openobject-server/trunk-bug-723662-ysa.
Revision No :- 3436
Revision ID : <email address hidden> and It will be merge soon
in trunk server.

Thanks,

Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

Thanks for the bug report.

The fix is available in trunk at revision 3633 (revision-id: <email address hidden>).

Changed in openobject-server:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.