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