formatLang will not format string date like 2009-01-01 even if date=True

Bug #497423 reported by Nicolas Bessi - Camptocamp
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Undecided
OpenERP Core Team
Nominated for 5.0 by Nicolas Bessi - Camptocamp
Nominated for Trunk by Nicolas Bessi - Camptocamp

Bug Description

formatLang will not formate string date like '2009-01-01' even if date=True

The formatLang of sxw_report will not work on date string simply because the case is not handled right in the test and it will systematically return the value.

By the way this function is quite messy and should be (partially) rewritten.
There is a lot of odd lines
Things likes :
type(value) == type('')
isinstance(value, (str, unicode))

That should be more like isinstance(obj, basestring)

or

if (not date_time):

Regards

Nicolas

Related branches

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

If you agree I will propose a cleaning of this version ASAP

Changed in openobject-server:
assignee: nobody → OpenERP Quality Team (openerp)
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Nicolas,

I disagree here. The formatLang option clearly says that it should be a date or datetiem object if you want it to be formatted.

Example : formatLang(invoice.date_invoice,date=True).

If the string is passed instead of an object ,the string will be returned.

However, you are welcomed for your suggestions. It would be helpful for us if that changes proopsed by you are better than the existing one.

Feel free to post them. We appreciate your interest.

Thank you.

Changed in openobject-server:
status: New → Invalid
Changed in openobject-server:
status: Invalid → New
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Hello

Ok I understand, but a little docstring in the function may be useful ;).
So if I understand what you said that mean there are errors in some of the account reports. Because

in the Wizard we have :

'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
That return a string representation of a date.

and in the RML

 <para style="terp_tblheader_General_Centre">[[ formatLang(data['form']['date1'],date = True) ]]</para>

So if I understand well the date will never be formatted.

Regards

Nicolas

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

Yes Nicolas,

I met to the error in one report. It actually should not check for string/unicode,should directly use strptime().
It has been fixed by revision 1923 <email address hidden>.

However, you are welcomed for your suggestions. It would be helpful for us if that changes proopsed by you are better than the existing one.

Feel free to post them. We appreciate your interest.

Thank you.

summary: - formatLang will not formate string date like 2009-01-01 even if
- date=True
+ formatLang will not format string date like 2009-01-01 even if date=True
Changed in openobject-server:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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