clinic/netforce_clinic/models/hd_case_discont.py

41 lines
1.1 KiB
Python
Raw Normal View History

2014-10-05 09:43:28 +00:00
from netforce.model import Model, fields, get_model
class HDCaseDiscont(Model):
_name="clinic.hd.case.discont"
_transient=True
_fields={
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
"note": fields.Text("Description"),
}
def _get_hd_case_id(self,context={}):
hd_case_id=context.get("refer_id")
2014-11-14 01:58:12 +00:00
print("hd case deault")
2014-10-05 09:43:28 +00:00
if not hd_case_id:
return None
return int(hd_case_id)
_defaults={
'hd_case_id': _get_hd_case_id,
}
def do_discontinue(self,ids,context):
obj=self.browse(ids)[0]
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
hd_case.write({
'note': obj.note,
2014-10-23 04:43:39 +00:00
'state': 'in_completed',
2014-10-05 09:43:28 +00:00
})
return {
'next': {
'name': 'clinic_hd_case',
'mode': 'form',
'active_id': hd_case.id,
},
'flash': '%s has been cancelled'%hd_case.number,
}
HDCaseDiscont.register()