Skip to Content
Menú
This question has been flagged
2 Respostes
3797 Vistes

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

Avatar
Descartar
Best Answer

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]




Avatar
Descartar
Best Answer

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]
Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
d’abr. 23
3254
2
de febr. 21
16399
1
d’oct. 20
3475
0
de set. 16
4397
1
d’abr. 16
6737