import time from netforce.model import Model from netforce.database import get_connection from netforce.access import get_active_company class Report(Model): _name="clinic.report" _store=False def cycle_recent_widget(self,context={}): db=get_connection() company_id=get_active_company() #datenow=time.strftime("%Y-%m-%d") #time_start='%s 00:00:00'%(datenow) #time_stop='%s 23:59:59'%(datenow) #res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id =%s and hd.date >= %s and hd.date <= %s group by c.name",company_id,time_start,time_stop) res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id =%s group by c.name",company_id) data=[] for r in res: data.append((r.name,r.count)) return {"value":data} Report.register()