Anup(OpenERP) has proposed merging
lp:~openerp-dev/openobject-client/6.0-opw-date_format_save_issue-ach into
lp:openobject-client/6.0.
Requested reviews:
Olivier Dony (OpenERP) (odo)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client/6.0-opw-date_format_save_issue-ach/+merge/52055
Hello,
When you have format that is having %A %B full names of month or day in
your date format its not possible to save the date due to the fmt_length that
is taken from the current date. Due to this it happens that we are trying to
select 'Wednesday September' but the date is having 'Friday May' so it will
take the length 10 so only 'Wednesday ' will be taken to convert.
The solution in the proposal solves the issue and now we are able to store
the date with any format.
Remember before this we also need to apply the changes in the branch
https://code.launchpad.net/~openerp-commiter/openobject-client/ach-6.0-opw-lp718040/+merge/50906
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-client/6.0-opw-date_format_save_issue-ach/+merge/52055
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-client/6.0-opw-date_format_save_issue-ach.
=== modified file 'bin/widget/view/form_gtk/calendar.py'
--- bin/widget/view/form_gtk/calendar.py 2011-01-12 12:44:53 +0000
+++ bin/widget/view/form_gtk/calendar.py 2011-03-03 12:32:46 +0000
@@ -43,7 +43,6 @@
def __init__(self, window, parent, model, attrs={}):
interface.widget_interface.__init__(self, window, parent, attrs=attrs)
self.format = user_locale_format.get_date_format()
- self.fmt_length = len((DT.now()).strftime(self.format))
self.widget = date_widget.ComplexEntry(self.format, spacing=3)
self.entry = self.widget.widget
self.entry.set_property('activates_default', True)
@@ -86,10 +85,11 @@
def get_value(self, model):
str = self.entry.get_text()
+ str = str.strip()
if str == '':
return False
try:
- date1 = DT.strptime(str[:self.fmt_length], self.format)
+ date1 = DT.strptime(str, self.format)
except:
return False
@@ -171,7 +171,6 @@
def __init__(self, window, parent, model, attrs={}):
interface.widget_interface.__init__(self, window, parent, model, attrs=attrs)
self.format = user_locale_format.get_datetime_format(True)
- self.fmt_length = len((DT.now()).strftime(self.format))
self.widget = date_widget.ComplexEntry(self.format, spacing=3)
self.entry = self.widget.widget
self.entry.set_property('activates_default', True)
@@ -212,9 +211,10 @@
def get_value(self, model, timezone=True):
str = self.entry.get_text()
+ str = str.strip()
if str=='':
return False
- return tools.datetime_util.local_to_server_timestamp(str[:self.fmt_length], self.format, DHM_FORMAT,
+ return tools.datetime_util.local_to_server_timestamp(str, self.format, DHM_FORMAT,
tz_offset=timezone, ignore_unparsable_time=False)
def set_value(self, model, model_field):
=== modified file 'bin/widget/view/tree_gtk/parser.py'
--- bin/widget/view/tree_gtk/parser.py 2011-01-18 06:45:01 +0000
+++ bin/widget/view/tree_gtk/parser.py 2011-03-03 12:32:46 +0000
@@ -429,7 +429,6 @@
def __init__(self, *args):
self.server_format = '%Y-%m-%d'
self.display_format = user_locale_format.get_date_format()
- self.fmt_length = len((DT.datetime.now()).strftime(self.display_format))
super(Date, self).__init__(*args)
@@ -437,7 +436,6 @@
def __init__(self, *args):
self.server_format = '%Y-%m-%d %H:%M:%S'
self.display_format = user_locale_format.get_datetime_format(True)
- self.fmt_length = len((DT.datetime.now()).strftime(self.display_format))
super(Datetime, self).__init__(*args)
def get_textual_value(self, model):
@@ -453,7 +451,8 @@
def value_from_text(self, model, text):
if not text:
return False
- return tools.datetime_util.local_to_server_timestamp(text[:self.fmt_length],
+ text = text.strip()
+ return tools.datetime_util.local_to_server_timestamp(text,
self.display_format, self.server_format)
class Float(Char):
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-web
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-web
More help : https://help.launchpad.net/ListHelp