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="sequence"/>
<field name="department_id"/> <field name="department_id"/>
<field name="note"/> <field name="note"/>
<field name="active"/>
<field name="branch_id" invisible="1"/> <field name="branch_id" invisible="1"/>
<field name="company_id" invisible="1"/> <field name="company_id" invisible="1"/>
<related> <related>

View File

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

View File

@ -4,7 +4,7 @@ from calendar import monthrange
from datetime import datetime, timedelta from datetime import datetime, timedelta
#from calendar import monthrange #from calendar import monthrange
from netforce.model import Model, fields, get_model 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 from . import utils
@ -25,6 +25,7 @@ class VisitBoard(Model):
_string="Visit Board" _string="Visit Board"
_transient=True _transient=True
_name_field="date" _name_field="date"
_fields={ _fields={
"date": fields.Date("Month", required=False), "date": fields.Date("Month", required=False),
"date_from": fields.Date("From", required=True), "date_from": fields.Date("From", required=True),
@ -36,10 +37,28 @@ class VisitBoard(Model):
'branch_id': fields.Many2One("clinic.branch","Branch"), '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={ _defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"), 'date': lambda *a: time.strftime("%Y-%m-%d"),
'date_from': 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"), '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={}): def get_report_data(self,ids,context={}):
@ -52,6 +71,12 @@ class VisitBoard(Model):
doctor_id=None doctor_id=None
department_id=None department_id=None
branch_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: if ids:
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
date_from=obj.date_from date_from=obj.date_from