GNU运行状况时区错误

2024-04-27 23:16:49 发布

您现在位置:Python中文网/ 问答频道 /正文

经过几天的搜索和尝试使用pytz和其他工具,我无法找到解决方案。在

当用户在GNU Health中创建药物打印列表时,会出现错误:

====== 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 be datetime.tzinfo, not None                  
============END================= 

我不知道如何纠正这个问题


Tags: inpyreportdatelineargsresultmethod
2条回答

您是否设置了机构/公司时区?在

您可以在参与方->配置->公司->时区中检查/设置您的公司时区

这是the current code for ^{}

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)

它似乎尝试(除非TZ=UTC您应该提交一个错误报告)来执行以下操作:

^{pr2}$

也就是说,它要么返回company时区的当前时间,要么返回本地时区的当前时间。在

相关问题 更多 >