import time from netforce.model import Model, fields, get_model class DialyzerDrop(Model): _name="report.dialyzer.drop" _string="Dialyzer [Drop]" _transient=True _fields={ "date": fields.Date("Date"), } _defaults={ 'date': lambda *a: time.strftime("%Y-%m-%d"), "state" : "drop", } def get_report_data(self,ids,context={}): lines=[] dialyzer_ids=get_model("clinic.dialyzer").search([["state","=","drop"]]) hd_cases=get_model("clinic.dialyzer").search_browse([]) for dialyzer_ids in hd_cases: lines.append({ 'number' : dialyzer_ids.number, 'usetime': dialyzer_ids.use_time, 'maxuse' : dialyzer_ids.max_use_time, 'createdate' : dialyzer_ids.date, 'expdate' : dialyzer_ids.exp_date, 'patient' : dialyzer_ids.patient_id.name, }) data={ 'lines': lines or "Dialyzer Drop [Empty]", } return data DialyzerDrop.register()