Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3863 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
apr 23
3318
2
feb 21
16473
1
ott 20
3509
0
set 16
4436
1
apr 16
6807