improve edit patient profile
							parent
							
								
									d7743fb6fc
								
							
						
					
					
						commit
						f3bc049338
					
				| 
						 | 
					@ -71,13 +71,14 @@ class Patient(Model):
 | 
				
			||||||
        res={}
 | 
					        res={}
 | 
				
			||||||
        for obj in self.browse(ids):
 | 
					        for obj in self.browse(ids):
 | 
				
			||||||
            dpt_codes=set()
 | 
					            dpt_codes=set()
 | 
				
			||||||
 | 
					            # main department
 | 
				
			||||||
 | 
					            dpt_codes.update({obj.department_id.code})
 | 
				
			||||||
 | 
					            # hd department
 | 
				
			||||||
            for dpt in obj.departments:
 | 
					            for dpt in obj.departments:
 | 
				
			||||||
                dpt_codes.update({dpt.code})
 | 
					                dpt_codes.update({dpt.code})
 | 
				
			||||||
            if not dpt_codes:
 | 
					            # cycle settings
 | 
				
			||||||
            for cline in obj.cycles:
 | 
					            for cline in obj.cycles:
 | 
				
			||||||
                dpt_codes.update({cline.department_id.code})
 | 
					                dpt_codes.update({cline.department_id.code})
 | 
				
			||||||
            if not dpt_codes:
 | 
					 | 
				
			||||||
                dpt_codes=[obj.department_id.code]
 | 
					 | 
				
			||||||
            res[obj.id]=','.join([code for code in dpt_codes if code])
 | 
					            res[obj.id]=','.join([code for code in dpt_codes if code])
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,17 @@ class PatientCycle(Model):
 | 
				
			||||||
        "department_id": fields.Many2One('clinic.department',"Department",search=True),
 | 
					        "department_id": fields.Many2One('clinic.department',"Department",search=True),
 | 
				
			||||||
        'day': fields.Selection([('mon', 'Monday'), ('tue','Tuesday'), ('wed','Wednesday'),('thu','Thursday'),('fri','Friday'),('sat','Saturday'),('sun','Sunday')], 'Day',search=True),
 | 
					        'day': fields.Selection([('mon', 'Monday'), ('tue','Tuesday'), ('wed','Wednesday'),('thu','Thursday'),('fri','Friday'),('sat','Saturday'),('sun','Sunday')], 'Day',search=True),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _get_department(self,context={}):
 | 
				
			||||||
 | 
					        data=context.get('data')
 | 
				
			||||||
 | 
					        if data and data.get('department_id'):
 | 
				
			||||||
 | 
					            return data['department_id']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _defaults={
 | 
				
			||||||
 | 
					        'department_id': _get_department,
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _sql_constraints=("pcycle_uniq","unique(patient_id,cycle_id,day,department_id)","patient_id,cycle_id,day,department_id should be unique"),
 | 
					    _sql_constraints=("pcycle_uniq","unique(patient_id,cycle_id,day,department_id)","patient_id,cycle_id,day,department_id should be unique"),
 | 
				
			||||||
 | 
					    _order="department_id,cycle_id"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PatientCycle.register()
 | 
					PatientCycle.register()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue