python - GNU Health - Timezone Errors -


after few days of search , trying use pytz , other tools, unable find solution.

when user creates medication print-out list in gnu health error given:

====== error=======================                  traceback (most recent call last): file "/trytond/protocols/jsonrpc.py", line 150, in _marshaled_dispatch  response['result'] = dispatch_method(method, params)  file "/trytond/protocols/jsonrpc.py", line 179, in _dispatch res = dispatch(*args) file "/trytond/protocols/dispatcher.py", line 161, in dispatch result = rpc.result(meth(*c_args, **c_kwargs))  file "/trytond/report/report.py", line 144, in execute type, data = cls.parse(action_report, records, data, {}) file "/trytond/modules/health/report/health_report.py", line 62, in            parse localcontext['print_date'] = get_print_date() file "/trytond/modules/health/report/health_report.py", line 42, in get_print_date return datetime.astimezone((dt.replace(tzinfo=none)) typeerror: astimezone() argument 1 must datetime.tzinfo, not none                   ============end=================  

i not sure how rectify issue

here's the current code get_print_date():

def get_print_date():     company = pool().get('company.company')      timezone = none     company_id = transaction().context.get('company')     if company_id:         company = company(company_id)         if company.timezone:             timezone = pytz.timezone(company.timezone)      dt = datetime.now()     return datetime.astimezone(dt.replace(tzinfo=pytz.utc), timezone) 

it seems tries (incorrectly unless tz=utc -- should submit bug report) following:

import tzlocal # $ pip install tzlocal  def get_print_date():     company = pool().get('company.company')     company_id = transaction().context.get('company')     company = company_id , company(company_id)     timezone = company , company.timezone , pytz.timezone(company.timezone)     return datetime.now(timezone or tzlocal.get_localzone()) 

i.e., either returns current time in company's timezone or in local timezone.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -