Invalid date format (locale en_IN)

Bug #295016 reported by Amit Mendapara
4
Affects Status Importance Assigned to Milestone
Odoo GTK Client (MOVED TO GITHUB)
Fix Released
Undecided
Unassigned

Bug Description

On Ubuntu Linux, The GTK client shows invalid date format for Indian locale en_IN. The date format for en_IN is `%A %d %B %Y` which is then converted by the client to `%d %Y'.

I have noticed that this problem occurs when the default locale `en_US` is not installed on your system. I think this might also affect other similar locales.

One possible workaround to this problem is to set `LDFMT = '%Y/%m/%d'` if setting locale fails (see translate.setlang).

description: updated
Revision history for this message
Amit Mendapara (cristatus) wrote :

Here is a patch to fix the problem...

Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :

I don't like your patch
I propose something like this...

Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :
Revision history for this message
Amit Mendapara (cristatus) wrote :

No, it won't work. You should set default date format only if `locale.setlocale` fails.

Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :

The problem is not because the en_US locale is not installed.
The problem will also occur if you set the en_IN locale in your preferences

The problem is that the indian date format (and others) use non-numeric representations (%a %A %b %B). So if the format contain one of these, we must use the default format

Revision history for this message
Amit Mendapara (cristatus) wrote :

I think the better solution would be to check the format string for `%Y`, `%m` and `%d` the separator `/` (IMHO masked datetime entry widget only understand such format). So...

============================================
import re

...

if not re.match('%Y\/%m\/%d)|(%m\/%d\/%Y)|(%d\/%m\/%Y)', LDFMT):
    LDFMT = '%Y/%m/%d'
============================================

would be the ideal solution...

Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :

No.
The separator may be a dash or any other character.

Revision history for this message
Stephane Wirtel (OpenERP) (stephane-openerp) wrote :

Can you check this error with Windows ? because there is a specific function for this platform.

Revision history for this message
Amit Mendapara (cristatus) wrote :

If separator can be anything then something like:

===========================
import re

...

if not (LDFMT.count('%Y') == 1 and LDFMT.count('%m') == 1 and LDFMT.count('%d') == 1):
    LDFMT = '%Y/%m/%d'

===========================

will do...

Revision history for this message
Amit Mendapara (cristatus) wrote :

I have seen another problem in search view which is related to this bug, preventing search within a date range. I have fixed the problem (not commited). Here is the patch...

Changed in openobject-client:
status: New → Fix Committed
Changed in openobject-client:
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

Remote bug watches

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