This question has been flagged
1 Reply
5173 Views

I have defined a field called 'datetime'. 

Here the time should be set to 08:00 by default and date we need to set manually.

How can we do this?

I did something like this, here am setting date and time by default. But unable to set only time.

_defaults = {

'date_start': lambda self,cr,uid,context=None: fields.date.context_today(self,cr,uid,context) + " 02:30:00",  

}

Please Suggest

Thanks

Avatar
Discard
Best Answer

date.fields.datetime('Creation Date', required=True),

given like this

_defaults = {
        'date': lambda *a: time.strftime('%Y-%m-%d 08:00:00'),
            }

Try like this...I think,it ll be work for your criteria

which field you want set default time.for example-

current_time.fields.char(string="Current Time: ",default=time.strftime('08:00:00'),readonly=True)

Avatar
Discard
Author

Thanks, actually what i need is date should be set manually from user and time should be set to 8 o' clock by default.

Try like this,, current_time.fields.char(string="Current Time: ",default=time.strftime('08:00:00'),readonly=True). think this ll be work for your case

Author

Thanks Bailey

Hello Tangaraj, i am also facing some issue.
deadline = fields.Datetime('Deadline', help="Date by which the person can open the survey and submit answers",
oldname="date_deadline", default=time.strftime('23:59:59'))
above field not working. My time should be 23:59 while date is manual