跳至內容
選單
此問題已被標幟
2 回覆
3810 瀏覽次數

Image Preview

what i want to do in my custom form that is on image preview ...
what i have done .....

in Py

tz = fields.Selection('_tz_get', string='Timezone', required=True, default=lambda self: self.env.user.tz or 'UTC')

in XML

<field name="tz"/>​


Error is 

object has no attribute '_tz_get'

any solution please

頭像
捨棄
最佳答案

Hello, 

Try this maybe it should work.

import pytz

date_tz = fields.Selection('_tz_get', string='Timezone', required=True, default=lambda self: self.env.user.tz or 'UTC')

@api.model
def _tz_get(self):
return [(x, x) for x in pytz.all_timezones]




頭像
捨棄
最佳答案

Hello,

the definition of 'tz_get' is missing:

you must add in py file

import pytz
@api.model
def _tz_get(self):
return [(x, x) for x in pytz.all_timezones]
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
4月 23
3258
2
2月 21
16419
1
10月 20
3478
0
9月 16
4403
1
4月 16
6742