fix
parent
ada182c083
commit
a8826b9b8e
|
@ -68,7 +68,7 @@ class Department(Model):
|
|||
'perms': perms,
|
||||
'other_perms': [('set',other_perms)],
|
||||
'login_company_id': get_active_company(),
|
||||
'home_action': 'clinic_board',
|
||||
'home_action': 'clinic_visit_board',
|
||||
})
|
||||
print("create profile %s"%(code))
|
||||
return profile_id
|
||||
|
|
|
@ -36,24 +36,29 @@ class VisitBoard(Model):
|
|||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
}
|
||||
|
||||
def _get_branch(self,context={}):
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
date=defaults.get('date',time.strftime("%Y-%m-%d"))
|
||||
date_from=defaults.get("date_from",time.strftime("%Y-%m-%d"))
|
||||
date_to=defaults.get("date_to")
|
||||
if not date_to:
|
||||
date_to=(datetime.now()+timedelta(days=DRT)).strftime("%Y-%m-%d")
|
||||
branch_id=defaults.get("branch_id")
|
||||
department_id=defaults.get("department_id")
|
||||
res=get_model('select.company').get_select()
|
||||
if res:
|
||||
print('res ', res)
|
||||
return res['branch_id']
|
||||
|
||||
def _get_department(self,context={}):
|
||||
res=get_model('select.company').get_select()
|
||||
if res:
|
||||
return res['department_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_department,
|
||||
'branch_id': _get_branch,
|
||||
}
|
||||
if not branch_id:
|
||||
branch_id=res['branch_id']
|
||||
if not department_id:
|
||||
department_id=res['department_id']
|
||||
res={
|
||||
'date': date,
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
}
|
||||
return res
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
company_id=get_active_company()
|
||||
|
@ -65,14 +70,10 @@ class VisitBoard(Model):
|
|||
doctor_id=None
|
||||
defaults=self.default_get(context=context)
|
||||
department_id=defaults.get("department_id",None)
|
||||
if department_id:
|
||||
department_id=department_id[0]
|
||||
branch_id=defaults.get("branch_id",None)
|
||||
if branch_id:
|
||||
branch_id=branch_id[0]
|
||||
print('defaults ', defaults)
|
||||
#user_id=get_active_user()
|
||||
#set_active_user(1) #FIXME to allow user to see doctor different department
|
||||
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
date_from=obj.date_from
|
||||
|
@ -82,10 +83,8 @@ class VisitBoard(Model):
|
|||
doctor_id=obj.doctor_id.id
|
||||
department_id=obj.department_id.id
|
||||
branch_id=obj.branch_id.id
|
||||
|
||||
time_start='%s 00:00:00'%(date_from)
|
||||
time_stop='%s 23:59:59'%(date_to)
|
||||
|
||||
dom=[]
|
||||
dom.append(['time_start','>=','%s'%time_start])
|
||||
dom.append(['time_stop','<=','%s'%time_stop])
|
||||
|
@ -99,7 +98,6 @@ class VisitBoard(Model):
|
|||
dom.append(['department_id','=',department_id])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
|
||||
lines=[]
|
||||
empty_line={
|
||||
'no': '',
|
||||
|
|
Loading…
Reference in New Issue