Hola
Es correcto lo que mencionas, yo solucioné este tema extendiendo la clase
DateTime
espero te sirva
saludos
class DateTime(metaclass=PoolMeta):
'Date Time'
__name__ = 'ir.date'
@classmethod
def time(cls, timezone=None):
"""
Get current date time according timezone
:param timezone: string representing standar time zone
:return: datetime with time zoned now
"""
return cls.now(timezone).strftime("%H:%M")
@classmethod
def now(cls, timezone=None):
"""
Get current date time according timezone
:param timezone: string representing standar time zone
:return: datetime with time zoned now
"""
Company = Pool().get('company.company')
company_id = Transaction().context.get('company')
if timezone is None and company_id:
company = Company(company_id)
if company.timezone:
timezone = pytz.timezone(company.timezone)
return datetime.now(timezone)
@classmethod
def localize(cls, utc_datetime, timezone=None):
"""
Localize utc_datetime according timzezone
:param utc_datetime: date without timezone, we will take this as utc
:param timezone: string with timezone we want to localize
:return: datetime with time zoned datetime
"""
if utc_datetime is None:
return None
Company = Pool().get('company.company')
company_id = Transaction().context.get('company')
if timezone is None and company_id:
company = Company(company_id)
if company.timezone:
timezone = pytz.timezone(company.timezone)
utc_datetime = pytz.timezone('UTC').localize(utc_datetime)
return utc_datetime.astimezone(timezone)
@classmethod
def localize_str(cls, utc_datetime, timezone=None):
""""
Localize utc_datetime according timzezone
:param utc_datetime: date without timezone, we will take this as utc
:param timezone: string with timezone we want to localize
:return: string with time zoned datetime
"""
localize = cls.localize(utc_datetime, timezone)
if localize is None:
return ''
return localize.strftime("%Y-%m-%d %H:%M")
2018-07-25 9:25 GMT-05:00 JUAN ROBLES <[email protected]>:
> Sorry , para ser mas especifico " Pero logre solucionarlo agregando la
> sentencia timezone:'local' en las lineas de sentencia referidas al
> fullcalendar en el .js del cliente web, por si alguien pasa el mismo
> problema. "
>
> Aclarando que hay podemos agregar otras vistas (dias) , modificar la forma
> de ver fechas , rangos de tiempo , etc.
>
> El 25 de julio de 2018, 03:02, JUAN ROBLES<[email protected]>
> escribió:
>
>> Gracias por el interés, Este es el escenario a nivel funcional;
>>
>> 1, Agendo una cita en el módulo health y me dirijo a la vista calendario
>> (Con el perfil de un Dr.).
>>
>> 2. Doy click en la fecha que deseo agendar la cita.
>>
>> 3. coloco la fechas de inicio y final de la cita y al momento de dar
>> click a guardar, la hora de inicio se guarda y se le resta 5 horas
>>
>> Pero logre solucionarlo agregando la sentencia timezone:local en el js
>> del cliente web, por si alguien pasa el mismo problema.
>>
>>
>> El 24 de julio de 2018, 20:53, Carlos Eduardo Sotelo Pinto<
>> [email protected]> escribió:
>>
>>> Hola
>>>
>>> No me queda claro el tema, sin embargo es cierto que hay un tema con el
>>> manejo de horas en gnu health, no se si puedas pasar una secuencia logica
>>> para poder reproducirla y darte una mano
>>>
>>> saludos
>>>
>>> 2018-07-24 14:08 GMT-05:00 <[email protected]>:
>>>
>>>> Buenos días Comunidad , le solicito su gentil apoyo ; tengo problema
>>>> vengo utilizando tryton 4.2 con el modulo GNUHEALTH - CALENDAR ; Lo que
>>>> sucede es cuando voy a la vista calendario y doy click a la hora para
>>>> agendar me carga de manera normal la vista clásica similar a evento del
>>>> calendario del tryton (vista form) pero al guardar se restan 5 horas al
>>>> inicio del evento, asumo que es un tema relacionado al GTM porque soy de
>>>> Perú y somos GTM -5.
>>>> Utilizo el cliente Web.
>>>>
>>>> Los descartes realizados :
>>>> - Se configuro la zona horaria de la Empresa donde esta asociada la
>>>> persona con America/Lima
>>>> - Se configuro correctamente la hora del servidor.
>>>>
>>>> Ojala me pueda apoyar.
>>>>
>>>>
>>>
>>>
>>> --
>>> Carlos Eduardo Sotelo Pinto
>>> Agile Coach | Python Software Developer | Tryton ERP Consultant
>>> Claro RPC +51 989550602 <989%20550%20602>
>>> Skype: csotelop
>>> GNULinux RU #379182 | GNULinux RM #277661
>>>
>>> *Please consider the environment before printing this email*
>>>
>>> *Join the campaign at http://thinkBeforePrinting.org
>>> <http://thinkBeforePrinting.org>*
>>>
>>
>>
>
--
Carlos Eduardo Sotelo Pinto
Agile Coach | Python Software Developer | Tryton ERP Consultant
Claro RPC +51 989550602 <989%20550%20602>
Skype: csotelop
GNULinux RU #379182 | GNULinux RM #277661
*Please consider the environment before printing this email*
*Join the campaign at http://thinkBeforePrinting.org
<http://thinkBeforePrinting.org>*