fix
							parent
							
								
									e5cd180a9c
								
							
						
					
					
						commit
						62c044f070
					
				| 
						 | 
				
			
			@ -103,6 +103,15 @@ class CycleItem(Model):
 | 
			
		|||
 | 
			
		||||
    def validate(self,ids,context={}):
 | 
			
		||||
        obj=self.browse(ids)[0]
 | 
			
		||||
        #prevent duplicate nurse
 | 
			
		||||
        ns={}
 | 
			
		||||
        for line in obj.lines:
 | 
			
		||||
            nurse=line.nurse_id
 | 
			
		||||
            if not ns.get(nurse.id):
 | 
			
		||||
                ns[nurse.id]=1
 | 
			
		||||
            else:
 | 
			
		||||
                raise Exception("Duplicate %s"%nurse.name)
 | 
			
		||||
 | 
			
		||||
        for hdcase in obj.hd_cases:
 | 
			
		||||
            state=hdcase.state
 | 
			
		||||
            if state=='cancelled':
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1475,6 +1475,16 @@ class HDCase(Model):
 | 
			
		|||
        self.function_store(ids)
 | 
			
		||||
        super().write(ids,vals,**kw)
 | 
			
		||||
        obj=self.browse(ids)[0]
 | 
			
		||||
        # prevent duplicate doctor
 | 
			
		||||
        print('obj.state ', obj.state)
 | 
			
		||||
        if obj.state in ('waiting_payment', 'paid'):
 | 
			
		||||
            st={}
 | 
			
		||||
            for lstaff in obj.staffs:
 | 
			
		||||
                staff=lstaff.staff_id
 | 
			
		||||
                if not st.get(staff.id):
 | 
			
		||||
                    st[staff.id]=1
 | 
			
		||||
                else:
 | 
			
		||||
                    raise Exception("Douplicate %s"%staff.name)
 | 
			
		||||
        self.check_hct(obj)
 | 
			
		||||
 | 
			
		||||
    def approve(self,ids,context={}):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -311,18 +311,19 @@ class LaborCost(Model):
 | 
			
		|||
            if hd_case.state not in ('waiting_payment','paid'):
 | 
			
		||||
                continue
 | 
			
		||||
            staffs=hd_case.staffs
 | 
			
		||||
            if not staffs and dwalkin:
 | 
			
		||||
                staff=dwalkin
 | 
			
		||||
                staff_total[staff.id]={
 | 
			
		||||
                    'base': 0,
 | 
			
		||||
                    'type': staff.type,
 | 
			
		||||
                    'categ_id': staff.categ_id.id,
 | 
			
		||||
                    'level_id': staff.level_id.id,
 | 
			
		||||
                    'qty': 0,
 | 
			
		||||
                 }
 | 
			
		||||
            doctor_id=hd_case.doctor_id
 | 
			
		||||
            if not doctor_id and dwalkin:
 | 
			
		||||
                if not staff_total.get(dwalkin.id):
 | 
			
		||||
                    staff_total[dwalkin.id]={
 | 
			
		||||
                        'base': 0,
 | 
			
		||||
                        'type': dwalkin.type,
 | 
			
		||||
                        'categ_id': dwalkin.categ_id.id,
 | 
			
		||||
                        'level_id': dwalkin.level_id.id,
 | 
			
		||||
                        'qty': 0,
 | 
			
		||||
                     }
 | 
			
		||||
                base=cost_per_case
 | 
			
		||||
                staff_total[staff.id]['base']=base
 | 
			
		||||
                staff_total[staff.id]['qty']+=1
 | 
			
		||||
                staff_total[dwalkin.id]['base']=base
 | 
			
		||||
                staff_total[dwalkin.id]['qty']+=1
 | 
			
		||||
            else:
 | 
			
		||||
                for ps in staffs:
 | 
			
		||||
                    staff=ps.staff_id or dwalkin
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -313,7 +313,7 @@ class MatchingHDCase(Model):
 | 
			
		|||
        if date_from==date_to:
 | 
			
		||||
            date=date_from
 | 
			
		||||
        data={
 | 
			
		||||
            'lines': lines,
 | 
			
		||||
            'lines': sorted(lines,key=lambda x: x.get('date')),
 | 
			
		||||
            'date_from': date_from,
 | 
			
		||||
            'date_to': date_to,
 | 
			
		||||
            'date': date,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -184,10 +184,11 @@ class ReportLaborCost(Model):
 | 
			
		|||
                        ndata[dpt_name]={
 | 
			
		||||
                            'hdcases': set(),
 | 
			
		||||
                            'department_id': department.id,
 | 
			
		||||
                            'branch_id':department.branch_id.id,
 | 
			
		||||
                            'branch_id': department.branch_id.id,
 | 
			
		||||
                        }
 | 
			
		||||
                    for hdcase in citem.hd_cases:
 | 
			
		||||
                        ndata[dpt_name]['hdcases'].update({hdcase.id})
 | 
			
		||||
                        if hdcase.state in ('waiting_payment','paid'):
 | 
			
		||||
                            ndata[dpt_name]['hdcases'].update({hdcase.id})
 | 
			
		||||
            total_amount=0
 | 
			
		||||
            for categ_name,vals in ctdata.items():
 | 
			
		||||
                amount=vals['amount'] or 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,8 +56,9 @@ class ReportThaiWHTCertif(Model):
 | 
			
		|||
            else:
 | 
			
		||||
                if contact_type!=comp.contact_type:
 | 
			
		||||
                    raise Exception("Different WHT contact types for same payment")
 | 
			
		||||
            print('sequence ', comp.sequence)
 | 
			
		||||
            exp_code=comp.sequence or "5"
 | 
			
		||||
            exp_code=exp_code.replace(".","_")
 | 
			
		||||
            print('sequence ', exp_code)
 | 
			
		||||
            #if comp.exp_type=="salary":
 | 
			
		||||
                #exp_code="1"
 | 
			
		||||
            #elif comp.exp_type=="commission":
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue