search method compare of current date which is date format with date_open is crm_lead field which is string format how to do that
def get_name(self, form):
crm_obj = self.pool.get('crm.lead')
sale_obj=self.pool.get('hr.employee')
line=[]
d = datetime.now().date()
currentdate=time.strftime('%Y-%m-%d')
cur_date=datetime.strptime(currentdate,'%Y-%m-%d')
line=crm_obj.browse(self.cr, self.uid, self.ids)
targetselect=form['target_selection']
for val in line:
nameop=val.date_open
cdate=datetime.strptime(nameop,'%Y-%m-%d %H:%M:%S').date()
gval=val.id
print type(nameop),cdate,type(cdate),gval,cur_date,targetselect,d,"hhhhhhhhhhhhhhhhhhhhhhhhhhh"
if targetselect=='daily':
print cdate,d,"111111111111111111111111111111"
lines=crm_obj.search(self.cr, self.uid, [('date_open','==',d)])
print lines
else:
raise osv.except_osv(_('Info'),_('There is no entry for today'))
print x
So what is the issue?
lines=crm_obj.search(self.cr, self.uid, [('date_open','==',d)]) if i do that error gives as object of type 'datetime.date' has no len() date_open-->string of date time field and d->currentdate
date_open is a datetime type or only date type?
date_open is a string type and time.strftime("%Y-%m-%d") is a datetime.date type, will the compare happen(i check your updated code it still loading the web page no result produced)