From 016d0be817529598d9696e253c278c371d140deb Mon Sep 17 00:00:00 2001 From: dufresnedavid Date: Wed, 11 Jan 2017 12:17:27 -0500 Subject: [PATCH] Fix user timezone in attachments_to_filesystem --- attachments_to_filesystem/models/ir_attachment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/attachments_to_filesystem/models/ir_attachment.py b/attachments_to_filesystem/models/ir_attachment.py index 69fbaa71..b5603d05 100644 --- a/attachments_to_filesystem/models/ir_attachment.py +++ b/attachments_to_filesystem/models/ir_attachment.py @@ -61,7 +61,8 @@ class IrAttachment(Model): user = self.pool['res.users'].browse(cr, uid, uid, context=context) next_night = datetime.now() + relativedelta( hour=01, minute=42, second=0) - next_night = pytz.timezone(user.tz).localize(next_night).astimezone( + user_tz = user.tz or 'UTC' + next_night = pytz.timezone(user_tz).localize(next_night).astimezone( pytz.utc).replace(tzinfo=None) if next_night < datetime.now(): next_night += relativedelta(days=1)