clinic/netforce_clinic/models/visit.py

52 lines
1.8 KiB
Python
Raw Normal View History

2014-08-19 11:36:46 +00:00
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
class Visit(Model):
_name="clinic.visit"
_string="Visit"
_audit_log=True
_name_field="number"
_multi_company=True
_fields={
"number": fields.Char("Number",required=True,search=True),
2014-10-01 10:52:21 +00:00
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
2014-08-19 11:36:46 +00:00
"doctor_id": fields.Many2One("clinic.doctor","Doctor",search=True),
"nurse_id": fields.Many2One("clinic.nurse","Nurse",search=True),
2014-10-01 10:52:21 +00:00
"visit_date": fields.Date("Visit Date",required=True,search=True),
2014-09-11 03:21:52 +00:00
"department": fields.Char("Department",required=False,search=True),
"cycle": fields.Selection([("1","One"),("2","Two"),("3","Tree"),("4","Four")],"Cycle",required=True),
"state": fields.Selection([("pending","Pending"),("confirmed","Confirmed"),("canceled","Canceled")],"Status",required=True),
2014-08-19 11:36:46 +00:00
"comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"),
}
def _get_number(self,context={}):
while 1:
num=get_model("sequence").get_number("sale_order")
if not num:
return None
res=self.search([["number","=",num]])
if not res:
return num
get_model("sequence").increment("sale_order")
_defaults={
2014-09-11 03:21:52 +00:00
"state": "pending",
2014-08-19 11:36:46 +00:00
"number": _get_number,
"company_id": lambda *a: get_active_company(),
}
2014-09-11 03:21:52 +00:00
_order="date asc,cycle asc"
2014-08-19 11:36:46 +00:00
2014-09-11 03:21:52 +00:00
def confirmed(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"confirmed"})
2014-08-19 11:36:46 +00:00
2014-09-11 03:21:52 +00:00
def canceled(self,ids,context={}):
2014-08-19 11:36:46 +00:00
obj=self.browse(ids)[0]
2014-09-11 03:21:52 +00:00
obj.write({"state":"canceled"})
2014-08-19 11:36:46 +00:00
Visit.register()