import time from netforce.model import Model, fields, get_model class HDReport(Model): _name="clinic.hd.report" _string="HD Report" _transient=True _fields={ "date": fields.Date("Date"), "cycle_id": fields.Many2One("clinic.cycle","Cycle"), } _defaults={ 'date': lambda *a: time.strftime("%Y-%m-%d"), } _order="cycle_id desc" def get_report_data(self,ids,context={}): lines=[] hd_case_ids=get_model("clinic.dialyzer").search([["state","=","completed"]]) hd_cases=get_model("clinic.hd.case").search_browse([]) for hd_case_ids in hd_cases: lines.append({ 'cycle' : hd_case_ids.cycle_id.name, 'patient': hd_case_ids.patient_id.name, 'doctor' : hd_case_ids.doctor_id.name, #'Patient_Type' : patient.type, 'total' : hd_case_ids.fee, 'rc_no' : hd_case_ids.number, #'dz' : hd_case.dialyzers, 'nurse' : hd_case_ids.nurse_id.name, }) #get_model('clinic.patient').search #[{'name': 1}, {'name': 2}] data={ 'cycle_id': hd_case_ids.cycle or "Empty Cyle", #'patient_id' : obj.patient or "", #'doctor_id' : obj.doctor or "", 'lines': lines, } return data HDReport.register()