Merge lp:~openerp-dev/openerp-web/trunk-bug-885289-vda into lp:openerp-web

Proposed by Vaibhav Darji
Status: Rejected
Rejected by: Xavier (Open ERP)
Proposed branch: lp:~openerp-dev/openerp-web/trunk-bug-885289-vda
Merge into: lp:openerp-web
Diff against target: 36 lines (+15/-4)
1 file modified
addons/web/static/src/js/formats.js (+15/-4)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/trunk-bug-885289-vda
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Needs Fixing
Review via email: mp+81702@code.launchpad.net

Description of the change

Through exception on unmatched date patern while formating.

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

This leads to displaying stuff, but it displays the wrong stuff:

* read_group groups by *month* (and year), and displays a value of the year and month as the group title, this patch changes to displaying a day as well. The day is *not* correct, you will have dates of e.g. "11/10/2011" under the group "01/11/2011"
* read_group returns a preformatted group title, this breaks it

review: Needs Fixing

Unmerged revisions

1419. By Vaibhav Darji

[FIX] web failed unmatched date format. format using Date.parse directly in case.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/js/formats.js'
2--- addons/web/static/src/js/formats.js 2011-10-27 12:54:48 +0000
3+++ addons/web/static/src/js/formats.js 2011-11-09 10:34:12 +0000
4@@ -41,8 +41,14 @@
5 // name_get value format
6 return value[1];
7 case 'datetime':
8- if (typeof(value) == "string")
9- value = openerp.web.auto_str_to_date(value);
10+ if (typeof(value) == "string") {
11+ try {
12+ value = openerp.web.auto_str_to_date(value);
13+ } catch(e) {
14+ value = Date.parse(value);
15+ }
16+ }
17+
18 try {
19 return value.toString(_.sprintf("%s %s", Date.CultureInfo.formatPatterns.shortDate,
20 Date.CultureInfo.formatPatterns.longTime));
21@@ -51,8 +57,13 @@
22 }
23 return value;
24 case 'date':
25- if (typeof(value) == "string")
26- value = openerp.web.auto_str_to_date(value);
27+ if (typeof(value) == "string") {
28+ try {
29+ value = openerp.web.auto_str_to_date(value);
30+ } catch(e) {
31+ value = Date.parse(value);
32+ }
33+ }
34 try {
35 return value.toString(Date.CultureInfo.formatPatterns.shortDate);
36 } catch (e) {