master
David Janssens 2014-08-19 11:49:13 +07:00
commit bd85797762
14 changed files with 99 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,11 @@
<form model="hos.visit">
<head>
<field name="state"/>
</head>
<field name="date"/>
<field name="patient_id"/>
<field name="xxx"/>
<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,6 @@
<model name="hos.visit" string="Visit">
<field name="date" string="Date" type="date" required="1" search="1"/>
<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_js",
"description": "Hospital demo module (javascript)",
"version": "0.1"
}

View File

@ -0,0 +1,19 @@
var moment=require("moment");
add_method("hos.patient","get_age",function(ids) {
var vals={};
var now=moment();
this.browse(ids).forEach(function(obj) {
vals[obj.id]=now.diff(obj.birth_date,"years");
});
return vals;
});
add_method("hos.visit","set_done",function(ids) {
var obj=this.browse(ids)[0];
obj.write({"state":"done"});
});
add_default("hos.visit","date",function() {
return moment().format("YYYY-MM-DD");
});