40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
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")
|
|
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,
|
|
'state': 'in_completed',
|
|
})
|
|
return {
|
|
'next': {
|
|
'name': 'clinic_hd_case',
|
|
'mode': 'form',
|
|
'active_id': hd_case.id,
|
|
},
|
|
'flash': '%s has been cancelled'%hd_case.number,
|
|
}
|
|
|
|
HDCaseDiscont.register()
|
|
|