[FIX] web: format.js, toString while parsing date
authorDenis Ledoux <dle@odoo.com>
Tue, 24 Jun 2014 11:53:02 +0000 (13:53 +0200)
committerDenis Ledoux <dle@odoo.com>
Tue, 24 Jun 2014 11:53:02 +0000 (13:53 +0200)
When attempting to parse client date, value is not always a string.
We force the toString when adding the leading 0, as the replace method is for string

addons/web/static/src/js/formats.js

index cf53d9f..aa40975 100644 (file)
@@ -266,7 +266,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
                     value, (date_pattern + ' ' + time_pattern));
             if (datetime !== null)
                 return instance.web.datetime_to_str(datetime);
-            datetime = Date.parseExact(value.replace(/\d+/g, function(m){
+            datetime = Date.parseExact(value.toString().replace(/\d+/g, function(m){
                 return m.length === 1 ? "0" + m : m ;
             }), (date_pattern + ' ' + time_pattern));
             if (datetime !== null)
@@ -279,7 +279,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
             var date = Date.parseExact(value, date_pattern);
             if (date !== null)
                 return instance.web.date_to_str(date);
-            date = Date.parseExact(value.replace(/\d+/g, function(m){
+            date = Date.parseExact(value.toString().replace(/\d+/g, function(m){
                 return m.length === 1 ? "0" + m : m ;
             }), date_pattern);
             if (date !== null)