2014-08-19 11:36:46 +00:00
|
|
|
import time
|
2014-10-01 10:52:21 +00:00
|
|
|
|
|
|
|
from netforce.model import Model, fields, get_model
|
2014-08-19 11:36:46 +00:00
|
|
|
from netforce.access import get_active_company
|
|
|
|
|
|
|
|
class Nurse(Model):
|
|
|
|
_name="clinic.nurse"
|
|
|
|
_string="Nurse"
|
|
|
|
_audit_log=True
|
|
|
|
_name_field="name"
|
|
|
|
_multi_company=True
|
|
|
|
_fields={
|
2014-10-01 08:44:03 +00:00
|
|
|
"number": fields.Char("Nurse No.",required=True,search=True),
|
2014-10-01 10:52:21 +00:00
|
|
|
"name": fields.Char("Name",required=True,search=True),
|
2014-10-01 08:44:03 +00:00
|
|
|
"card_id" : fields.Char("Identity ID"),
|
|
|
|
"card_expire" : fields.Date("Expire Date"),
|
2014-10-01 09:30:37 +00:00
|
|
|
"birthday": fields.Date("Date of Birth",search=True),
|
|
|
|
"telephone": fields.Char("Telephone",search=True),
|
2014-10-01 10:52:21 +00:00
|
|
|
"type": fields.Selection([("temporary","Temporary"),("permanent","Permanent")],"Type"),
|
2014-10-01 08:44:03 +00:00
|
|
|
"mobile": fields.Char("Mobile",required=False,search=True),
|
2014-10-01 10:52:21 +00:00
|
|
|
"cert_no" : fields.Char("Certificate No."),
|
|
|
|
"cert_date" : fields.Date("Certificate Date"),
|
2014-10-01 09:30:37 +00:00
|
|
|
"birthday": fields.Date("BirthDay",search=True),
|
|
|
|
"telephone": fields.Char("Telephone",search=True),
|
|
|
|
"department_id": fields.Many2One("clinic.department", "Department",search=True),
|
|
|
|
"mobile": fields.Char("Mobile",search=True),
|
|
|
|
"state": fields.Selection([("draft","Draft"),("active","Active"),("deactive","Deactive")],"Status"),
|
2014-08-19 11:36:46 +00:00
|
|
|
"addresses": fields.One2Many("address","related_id","Addresses"),
|
|
|
|
"comments": fields.One2Many("message","related_id","Comments"),
|
|
|
|
"patients": fields.Many2Many("clinic.patient","Patients"),
|
2014-08-21 07:29:37 +00:00
|
|
|
"visits": fields.One2Many("clinic.visit","nurse_id","Visits"),
|
|
|
|
"hd_cases": fields.One2Many("clinic.hd.case","nurse_id","HD cases"),
|
2014-08-19 11:36:46 +00:00
|
|
|
"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-10-01 10:52:21 +00:00
|
|
|
"type": "temporary",
|
2014-08-19 11:36:46 +00:00
|
|
|
"date": lambda *a: time.strftime("%Y-%m-%d"),
|
|
|
|
"number": _get_number,
|
|
|
|
"company_id": lambda *a: get_active_company(),
|
|
|
|
}
|
|
|
|
_order="date desc,number desc"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def void(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
obj.write({"state":"voided"})
|
|
|
|
|
|
|
|
|
|
|
|
Nurse.register()
|