← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~therp-nl/ocb-server/6.1-lp1255612 into lp:ocb-server/6.1

 

Holger Brunn (Therp) has proposed merging lp:~therp-nl/ocb-server/6.1-lp1255612 into lp:ocb-server/6.1.

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1255612 in OpenERP Server: "appending times to dates when searching datetime doesn't take timezone into account"
  https://bugs.launchpad.net/openobject-server/+bug/1255612

For more details, see:
https://code.launchpad.net/~therp-nl/ocb-server/6.1-lp1255612/+merge/196958
-- 
https://code.launchpad.net/~therp-nl/ocb-server/6.1-lp1255612/+merge/196958
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~therp-nl/ocb-server/6.1-lp1255612 into lp:ocb-server/6.1.
=== modified file 'openerp/osv/expression.py'
--- openerp/osv/expression.py	2012-01-24 12:42:52 +0000
+++ openerp/osv/expression.py	2013-11-27 18:01:50 +0000
@@ -606,13 +606,22 @@
                 # other field type
                 # add the time part to datetime field when it's not there:
                 if field._type == 'datetime' and self.__exp[i][2] and len(self.__exp[i][2]) == 10:
-
                     self.__exp[i] = list(self.__exp[i])
 
+                    from openerp.osv import fields
+                    from openerp.tools.misc import DEFAULT_SERVER_DATE_FORMAT,\
+                            DEFAULT_SERVER_DATETIME_FORMAT
+                    date = fields.datetime.context_timestamp(
+                            cr, uid, datetime.datetime.strptime(
+                                self.__exp[i][2], DEFAULT_SERVER_DATE_FORMAT))
+
                     if operator in ('>', '>='):
-                        self.__exp[i][2] += ' 00:00:00'
+                        self.__exp[i][2] = date.strftime(
+                                DEFAULT_SERVER_DATETIME_FORMAT)
                     elif operator in ('<', '<='):
-                        self.__exp[i][2] += ' 23:59:59'
+                        self.__exp[i][2] = (date + datetime.timedelta(
+                            hours=23, minutes=59, seconds=59)).strftime(
+                                    DEFAULT_SERVER_DATETIME_FORMAT)
 
                     self.__exp[i] = tuple(self.__exp[i])
 


Follow ups