timezone info on datetime values ignored

Bug #1257807 reported by Ethan Furman
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

If a datetime value is given to OpenERP with timezone information, the timezone is stripped and the value is treated as UTC.

OpenERP 7.0

Revision history for this message
Ethan Furman (ethan-stoneleaf) wrote :
Revision history for this message
Twinkle Christian(OpenERP) (tch-openerp) wrote :

Hello Ethan,

Would you please provide more information on this issue ? As I am not understand with this enough information. Please provide proper scenario.

Waiting for your answer.
Thanks .

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Ethan Furman (ethan-stoneleaf) wrote :

I have a module which lets the user set a date and a time for a certain operation. Because the datetime widget is difficult to use I have them enter the data as a separate date field and time field, which I then combine into a third datetime field. If I submit this calculated datetime field as-is, OpenERP thinks it's in the UTC timezone. When I add the local timezone info to the calculated datetime so that I am now passing a timezone aware object to OpenERP, OpenERP ignores it and still treats it as a naive datetime in the UTC timezone.

Here's the code from my module:

    def _calc_appointment(self, cr, uid, ids, _field=None, _arg=None, context=None):
        if context is None:
            context = {}
        result = {}
        user_tz = get_user_timezone(self, cr, uid)[uid]
        if user_tz:
            user_tz = timezone(user_tz)
        for id in ids:
            result[id] = False
            record = self.browse(cr, uid, id, context=context)
            date = record.appointment_date
            time = record.appointment_time or 0.0
            if date:
                if not user_tz:
                    continue
                dt = DateTime.combine(Date(date), Time.fromfloat(time)).datetime()
                dt = user_tz.localize(dt)
                result[id] = dt
        return result

    _columns = {
        ...
        'appointment_date': fields.date('Appointment date', help="Date when driver should arrive."),
        'appointment_time': fields.float('Appointment time', help="Time when driver should arrive."),
        'appointment': fields.function(_calc_appointment, type='datetime', string='Appointment',
                store={'fnx.sr.shipping': (_calc_appointment, ['appointment_date', 'appointment_time'], 10)}),
         ...

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for OpenERP Server because there has been no activity for 60 days.]

Changed in openobject-server:
status: Incomplete → Expired
Changed in openobject-server:
status: Expired → New
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.