master
David Janssens 2014-08-19 12:49:02 +07:00
commit 609f6cfc03
14 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,7 @@
{
"name": "hos_board",
"view": "board",
"string": "Dashboard",
"view_layout": "hos_board",
"menu": "hos_menu"
}

View File

@ -0,0 +1,7 @@
{
"name": "hos_patient",
"view": "multi_view",
"string": "Patients",
"model": "hos.patient",
"menu": "hos_menu"
}

View File

@ -0,0 +1,7 @@
{
"name": "hos_visit",
"view": "multi_view",
"string": "Visits",
"model": "hos.visit",
"menu": "hos_menu"
}

View File

@ -0,0 +1,2 @@
<board>
</board>

View File

@ -0,0 +1,5 @@
<inherit inherit="main_menu">
<item string="General" position="before">
<item string="Hospital" action="hos_board"/>
</item>
</inherit>

View File

@ -0,0 +1,5 @@
<menu string="Hospital">
<item string="Dashboard" action="hos_board"/>
<item string="Patients" action="hos_patient"/>
<item string="Visits" action="hos_visit"/>
</menu>

View File

@ -0,0 +1,8 @@
<form model="hos.patient">
<field name="name"/>
<field name="birth_date"/>
<related>
<field name="visits"/>
<field name="addresses"/>
</related>
</form>

View File

@ -0,0 +1,5 @@
<list model="hos.patient">
<field name="name"/>
<field name="birth_date"/>
<field name="age"/>
</list>

View File

@ -0,0 +1,12 @@
<form model="hos.visit">
<head>
<field name="state"/>
</head>
<field name="date"/>
<field name="patient_id"/>
<field name="xxx"/>
<field name="other_patients"/>
<foot>
<button string="Completed" method="set_done" states="planned"/>
</foot>
</form>

View File

@ -0,0 +1,5 @@
<list model="hos.visit">
<field name="date"/>
<field name="patient_id"/>
<field name="state"/>
</list>

View File

@ -0,0 +1,7 @@
<model name="hos.patient" string="Patient">
<field name="addresses" string="Addresses" type="one2many" relation="address" relfield="related_id"/>
<field name="age" string="Age" type="integer" function="get_age"/>
<field name="birth_date" string="Birth Date" type="date" search="1"/>
<field name="name" string="Name" type="char" required="1" search="1"/>
<field name="visits" string="Visits" type="one2many" relation="hos.visit" relfield="patient_id"/>
</model>

View File

@ -0,0 +1,7 @@
<model name="hos.visit" string="Visit">
<field name="date" string="Date" type="date" required="1" search="1"/>
<field name="other_patients" string="Other Patients" type="many2many" relation="hos.patient"/>
<field name="patient_id" string="Patient" type="many2one" relation="hos.patient" search="1"/>
<field name="state" string="Status" type="selection" selection="[[&quot;planned&quot;,&quot;Planned&quot;],[&quot;done&quot;,&quot;Completed&quot;]]" search="1" default="planned"/>
<field name="xxx" string="XXX" type="char"/>
</model>

5
module.json 100644
View File

@ -0,0 +1,5 @@
{
"name": "hospital_demo_py",
"description": "Hospital demo module (python)",
"version": "0.1"
}

View File

@ -0,0 +1,22 @@
from datetime import *
from dateutil.relativedelta import *
@add_method("hos.patient")
def get_age(self,ids,context={}):
vals={}
for obj in self.browse(ids):
if obj.birth_date:
age=relativedelta(datetime.today(),datetime.strptime(obj.birth_date,"%Y-%m-%d")).years
else:
age=None
vals[obj.id]=age
return vals
@add_method("hos.visit")
def set_done(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"done"})
@add_default("hos.visit","date")
def get_date(self,context={}):
return datetime.today().strftime("%Y-%m-%d")