Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3831 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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]




Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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]
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 4 23
3281
2
thg 2 21
16446
1
thg 10 20
3485
0
thg 9 16
4417
1
thg 4 16
6760