I have written a function like below Written in Python and XML. Which function like if user selects past date it will display a warning message called 'Past date not allowed.' I need to get warning message like 'Past date not allowed. Date selected is 04-09-2015(It should display the selected date also). How can we do this.
Python:
def onchange_start_date_past(self, cr, uid, ids, start_date, eofdate, year2, context=None):
res = {'value':{}}
chng_year = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
today = time.strftime('%Y-%m-%d %H:%M:%S')
current_date = datetime.strptime(today, '%Y-%m-%d %H:%M:%S')
if chng_year.year and year2:
if str(chng_year.year) != str(year2):
#res['value']['date_start'] = ''
res.update({'warning': {'title': _('Warning !'), 'message': _('Please enter correct Year.')}})
return res
d = self.months_between1(chng_year, current_date)
if d < 0:
#res['value']['date_start'] = ''
res.update({'warning': {'title': _('Warning !'), 'message': _('Past date not allowed.')}})
return res
return start_date
else:
return False
XML:
<field name='date_start' on_change="onchange_start_date_past(date_start, date_end, parent.year)"/>
@hardikgiri Goswami Thanks a lot
Please accept the answer.