visit board

conv_bal
watcha.h@almacom.co.th 2015-01-21 18:31:51 +07:00
parent 225e980bd7
commit 3a13aa1919
3 changed files with 29 additions and 1 deletions

View File

@ -10,6 +10,7 @@
<field name="sequence"/>
<field name="department_id"/>
<field name="note"/>
<field name="active"/>
<field name="branch_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<related>

View File

@ -38,6 +38,7 @@ class SickBed(Model):
'note': fields.Text("Note"),
'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True),
'department_id': fields.Many2One("clinic.department","Department",required=True, search=True),
'active': fields.Boolean("Active"),
}
def _get_branch(self,context={}):
@ -56,6 +57,7 @@ class SickBed(Model):
'sequence': 0,
'state': 'available',
'branch_id': _get_branch,
'active': True,
}
_order="branch_id,department_id,sequence,name"

View File

@ -4,7 +4,7 @@ from calendar import monthrange
from datetime import datetime, timedelta
#from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
from netforce.access import get_active_company, get_active_user
from . import utils
@ -25,6 +25,7 @@ class VisitBoard(Model):
_string="Visit Board"
_transient=True
_name_field="date"
_fields={
"date": fields.Date("Month", required=False),
"date_from": fields.Date("From", required=True),
@ -35,11 +36,29 @@ class VisitBoard(Model):
'department_id': fields.Many2One("clinic.department","Department"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
}
def _get_branch(self,context={}):
user_id=get_active_user()
sts=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
branch_id=None
if sts:
branch_id=sts[0].branch_id.id
return branch_id
def _get_deparment(self,context={}):
user_id=get_active_user()
sts=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
dpt_id=None
if sts:
dpt_id=sts[0].department_id.id
return dpt_id
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"),
'date_from': lambda *a: time.strftime("%Y-%m-%d"),
'date_to': lambda *a: (datetime.now()+timedelta(days=DRT)).strftime("%Y-%m-%d"),
'department_id': _get_deparment,
'branch_id': _get_branch,
}
def get_report_data(self,ids,context={}):
@ -52,6 +71,12 @@ class VisitBoard(Model):
doctor_id=None
department_id=None
branch_id=None
user_id=get_active_user()
sts=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
if sts:
department_id=sts[0].department_id.id
branch_id=sts[0].branch_id.id
if ids:
obj=self.browse(ids)[0]
date_from=obj.date_from