Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
3806 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
avr. 23
3257
2
févr. 21
16414
1
oct. 20
3476
0
sept. 16
4402
1
avr. 16
6738