In my odoo module I have a datetime field (prefered_date). What I want to do is that, no matter what time the user enters, the time is always set 10 am. I tried to do it with the following code. but is not working. The time is setting to 6 am instead of 10, Maybe it has something to do with timezone. What am I doing wrong?
@api.multi def write(self, values): if 'prefered_date' in values: date = datetime.strptime(values.get('prefered_date'), '%Y-%m-%d %H:%M:%S') newdate = date.replace(hour=10, minute=0) new = newdate.strftime("%Y-%m-%d %H:%M:%S") values['prefered_date'] = new return super(PostabilidadRequest, self).write(values)