fix
							parent
							
								
									7071d8d5c8
								
							
						
					
					
						commit
						774c96225d
					
				| 
						 | 
				
			
			@ -15,7 +15,7 @@
 | 
			
		|||
    <field name="last_name" required="1"/>
 | 
			
		||||
    <field name="doctor_id" required="1"/>
 | 
			
		||||
    <field name="department_id" required="1"/>
 | 
			
		||||
    <field name="walkin"/>
 | 
			
		||||
    <field name="walkin" onchange="onchange_walkin"/>
 | 
			
		||||
    <field name="vascular_acc"/>
 | 
			
		||||
    <field name="location" readonly="1"/>
 | 
			
		||||
    <field name="active" invisible="1"/>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,5 +2,6 @@
 | 
			
		|||
    <field name="date" required="1" span="2"/>
 | 
			
		||||
    <field name="staff_type" onchange="onchange_type" span="2"/>
 | 
			
		||||
    <field name="staff_id" domain='[["type","=",type]]' span="2"/>
 | 
			
		||||
    <field name="department_id" span="2"/>
 | 
			
		||||
    <field name="branch_id" span="2"/>
 | 
			
		||||
    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
 | 
			
		||||
</form>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -351,7 +351,7 @@ class Patient(Model):
 | 
			
		|||
            datenow=time.strftime("%Y-%m-%d")
 | 
			
		||||
            vdom=[
 | 
			
		||||
                ['patient_id','in',ids],
 | 
			
		||||
                ['visit_date','>',datenow],
 | 
			
		||||
                ['visit_date','>=',datenow],
 | 
			
		||||
                ['state','=','pending'],
 | 
			
		||||
                ['manual','=',False],
 | 
			
		||||
            ]
 | 
			
		||||
| 
						 | 
				
			
			@ -564,4 +564,14 @@ class Patient(Model):
 | 
			
		|||
                
 | 
			
		||||
        return data
 | 
			
		||||
 | 
			
		||||
    def onchange_walkin(self,context={}):
 | 
			
		||||
        data=context['data']
 | 
			
		||||
        if data['walkin']=='yes':
 | 
			
		||||
            res=get_model('clinic.staff').search([['number','=','walkin'],['type','=','doctor']])
 | 
			
		||||
            if res:
 | 
			
		||||
                data['doctor_id']=res[0]
 | 
			
		||||
        else:
 | 
			
		||||
            data['doctor_id']=None
 | 
			
		||||
        return data
 | 
			
		||||
 | 
			
		||||
Patient.register()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@ class ReportLaborCostDaily(Model):
 | 
			
		|||
        "staff_type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
 | 
			
		||||
        'staff_id': fields.Many2One("clinic.staff","Staff"),
 | 
			
		||||
        'department_id': fields.Many2One("clinic.department",'Department'),
 | 
			
		||||
        'branch_id': fields.Many2One("clinic.branch","Branch"),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    def default_get(self,field_names=None,context={},**kw):
 | 
			
		||||
| 
						 | 
				
			
			@ -21,11 +22,13 @@ class ReportLaborCostDaily(Model):
 | 
			
		|||
        staff_type=defaults.get("staff_type","doctor")
 | 
			
		||||
        staff_id=int(defaults.get('staff_id', "0"))
 | 
			
		||||
        department_id=int(defaults.get('department_id', "0"))
 | 
			
		||||
        branch_id=int(defaults.get('branch_id', "0"))
 | 
			
		||||
        res={
 | 
			
		||||
            'date': date,
 | 
			
		||||
            'staff_type': staff_type,
 | 
			
		||||
            'staff_id': staff_id and staff_id or None,
 | 
			
		||||
            'department_id': department_id and department_id or None,
 | 
			
		||||
            'branch_id': branch_id and branch_id or None,
 | 
			
		||||
        }
 | 
			
		||||
        print("res ", res)
 | 
			
		||||
        return res
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +40,7 @@ class ReportLaborCostDaily(Model):
 | 
			
		|||
        date=defaults.get("date")
 | 
			
		||||
        staff_id=defaults.get("staff_id")
 | 
			
		||||
        staff_type=defaults.get("staff_type")
 | 
			
		||||
        branch_id=defaults.get("branch_id")
 | 
			
		||||
        dpt_id=defaults.get("department_id")
 | 
			
		||||
        dom=[]
 | 
			
		||||
        if ids:
 | 
			
		||||
| 
						 | 
				
			
			@ -44,6 +48,7 @@ class ReportLaborCostDaily(Model):
 | 
			
		|||
            date=obj.date
 | 
			
		||||
            staff_id=obj.staff_id.id
 | 
			
		||||
            staff_type=obj.staff_type
 | 
			
		||||
            branch_id=obj.branch_id.id
 | 
			
		||||
            dpt_id=obj.department_id.id
 | 
			
		||||
        dom.append(['date','>=',date])
 | 
			
		||||
        dom.append(['date','<=',date])
 | 
			
		||||
| 
						 | 
				
			
			@ -55,6 +60,8 @@ class ReportLaborCostDaily(Model):
 | 
			
		|||
            dom.append(['staff_id','=',staff_id])
 | 
			
		||||
        if staff_type:
 | 
			
		||||
            dom.append(['type','=',staff_type])
 | 
			
		||||
        if branch_id:
 | 
			
		||||
            dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
 | 
			
		||||
        if dpt_id:
 | 
			
		||||
            dom.append(['labor_cost_id.cycle_item_id.department_id','=',dpt_id])
 | 
			
		||||
        print('dom ', dom)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -128,6 +128,7 @@ class ReportLaborCostDetail(Model):
 | 
			
		|||
            qty=0
 | 
			
		||||
            if staff.type=='doctor':
 | 
			
		||||
                for hdcase in citem.hd_cases:
 | 
			
		||||
                    if hdcase.state in ('waiting_payment','paid'):
 | 
			
		||||
                        doctor_id=hdcase.doctor_id.id
 | 
			
		||||
                        if staff.id==doctor_id:
 | 
			
		||||
                            qty+=1
 | 
			
		||||
| 
						 | 
				
			
			@ -141,6 +142,7 @@ class ReportLaborCostDetail(Model):
 | 
			
		|||
                    'staff_id': staff.id,
 | 
			
		||||
                    'staff_name': staff.name or "",
 | 
			
		||||
                    'staff_type': staff.type,
 | 
			
		||||
                    'department_id': department_id,
 | 
			
		||||
                    dpt.name: {
 | 
			
		||||
                        'amt': 0,
 | 
			
		||||
                        'qty': 0,
 | 
			
		||||
| 
						 | 
				
			
			@ -153,6 +155,7 @@ class ReportLaborCostDetail(Model):
 | 
			
		|||
                        'staff_id': staff.id,
 | 
			
		||||
                        'staff_name': staff.name or '',
 | 
			
		||||
                        'staff_type': staff.type,
 | 
			
		||||
                        'department_id': department_id,
 | 
			
		||||
                        dpt.name: {
 | 
			
		||||
                            'amt': 0,
 | 
			
		||||
                            'qty': 0,
 | 
			
		||||
| 
						 | 
				
			
			@ -199,7 +202,8 @@ class ReportLaborCostDetail(Model):
 | 
			
		|||
                'date': kdate,
 | 
			
		||||
                'staff_type': vals.get("staff_type"),
 | 
			
		||||
                'staff_id': vals.get("staff_id"),
 | 
			
		||||
                'labor_cost_id': vals.get("labor_cost_id")
 | 
			
		||||
                'labor_cost_id': vals.get("labor_cost_id"),
 | 
			
		||||
                'department_id':  vals.get('department_id'),
 | 
			
		||||
            }
 | 
			
		||||
            total_qty, total_amt=0, 0
 | 
			
		||||
            lvals['sub_lines']=[]
 | 
			
		||||
| 
						 | 
				
			
			@ -229,6 +233,8 @@ class ReportLaborCostDetail(Model):
 | 
			
		|||
        # summary as footer
 | 
			
		||||
        dpt_lines=[{'qty': 0, 'amt': 0} for dpt in dpts]
 | 
			
		||||
        for line in lines:
 | 
			
		||||
            line['branch_id']=branch_id
 | 
			
		||||
            line['department_id']=department_id
 | 
			
		||||
            i=0
 | 
			
		||||
            for sub_line in line['sub_lines']:
 | 
			
		||||
                dpt_lines[i]['qty']+=sub_line['qty'] or 0
 | 
			
		||||
| 
						 | 
				
			
			@ -271,7 +277,8 @@ class ReportLaborCostDetail(Model):
 | 
			
		|||
            'dpt_lines': dpt_lines,
 | 
			
		||||
            'show_all': show_count <=1 and True or False,
 | 
			
		||||
        }
 | 
			
		||||
        print('.... ', data['show_name'])
 | 
			
		||||
        print('department_id ', department_id)
 | 
			
		||||
        print('branch_id ', branch_id)
 | 
			
		||||
        return data
 | 
			
		||||
 | 
			
		||||
    def onchange_date(self,context={}):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -142,8 +142,9 @@ class ReportLaborCostSummary(Model):
 | 
			
		|||
            if staff.level_id:
 | 
			
		||||
                level=get_model("clinic.staff.level").browse(staff.level_id.id)
 | 
			
		||||
                level_name=level.name or ""
 | 
			
		||||
            if not staffs.get(staff.name):
 | 
			
		||||
                staffs[staff.name]={
 | 
			
		||||
            staff_name='%s %s'%(staff.first_name, staff.last_name)
 | 
			
		||||
            if not staffs.get(staff_name):
 | 
			
		||||
                staffs[staff_name]={
 | 
			
		||||
                'number': staff.number or '',
 | 
			
		||||
                'first_name': staff.first_name or "",
 | 
			
		||||
                'staff_id': staff.id,
 | 
			
		||||
| 
						 | 
				
			
			@ -156,14 +157,14 @@ class ReportLaborCostSummary(Model):
 | 
			
		|||
                    'qty': qty,
 | 
			
		||||
                    },
 | 
			
		||||
                }
 | 
			
		||||
            if not staffs[staff.name].get(dpt.name):
 | 
			
		||||
                staffs[staff.name].update({
 | 
			
		||||
            if not staffs[staff_name].get(dpt.name):
 | 
			
		||||
                staffs[staff_name].update({
 | 
			
		||||
                        dpt.name: {
 | 
			
		||||
                            'amt': 0,
 | 
			
		||||
                            'qty': qty,
 | 
			
		||||
                        }})
 | 
			
		||||
            staffs[staff.name][dpt.name]['amt']+=amt
 | 
			
		||||
            staffs[staff.name][dpt.name]['qty']+=qty
 | 
			
		||||
            staffs[staff_name][dpt.name]['amt']+=amt
 | 
			
		||||
            staffs[staff_name][dpt.name]['qty']+=qty
 | 
			
		||||
 | 
			
		||||
            if not citems.get(citem.id):
 | 
			
		||||
                qty=0
 | 
			
		||||
| 
						 | 
				
			
			@ -252,7 +253,13 @@ class ReportLaborCostSummary(Model):
 | 
			
		|||
        # run no
 | 
			
		||||
        nlines=[]
 | 
			
		||||
        no=1
 | 
			
		||||
        for line in sorted(lines, key=lambda x: (x['staff_name'],x['first_name'])):
 | 
			
		||||
        sort_key='staff_name'
 | 
			
		||||
        if staff_type=='nurse' and categ_id:
 | 
			
		||||
            categ=get_model('clinic.staff.categ').browse(categ_id) 
 | 
			
		||||
            if categ.name in ("FT","HP"):
 | 
			
		||||
                sort_key='number'
 | 
			
		||||
            
 | 
			
		||||
        for line in sorted(lines, key=lambda x: (x[sort_key])):
 | 
			
		||||
            line['no']=no
 | 
			
		||||
            nlines.append(line)
 | 
			
		||||
            no+=1
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,7 +79,15 @@
 | 
			
		|||
                        </td>
 | 
			
		||||
                    {{/each}}
 | 
			
		||||
                    <td style="text-align:right;">
 | 
			
		||||
                        {{#if ../../department_id}}
 | 
			
		||||
                            <a href="#name=clinic_report_labor_cost_daily&defaults.date={{date}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.department_id={{../../department_id}}&defaults.branch_id={{../../branch_id}}">{{currency total_qty zero=""}}</a>
 | 
			
		||||
                        {{else}}
 | 
			
		||||
                            {{#if ../../branch_id}}
 | 
			
		||||
                                <a href="#name=clinic_report_labor_cost_daily&defaults.date={{date}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.branch_id={{../../branch_id}}">{{currency total_qty zero=""}}</a>
 | 
			
		||||
                            {{else}}
 | 
			
		||||
                                <a href="#name=clinic_report_labor_cost_daily&defaults.date={{date}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}">{{currency total_qty zero=""}}</a>
 | 
			
		||||
                            {{/if}}
 | 
			
		||||
                        {{/if}}
 | 
			
		||||
                    </td>
 | 
			
		||||
                    <td style="text-align:right;">{{currency total_amt zero=""}}</th>
 | 
			
		||||
                </tr>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,8 +19,8 @@
 | 
			
		|||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
            <th rowspan="3">#</th>
 | 
			
		||||
            <th rowspan="3">รหัส</th>
 | 
			
		||||
            {{#ifeq staff_type "nurse"}}
 | 
			
		||||
                <th rowspan="3">รหัส</th>
 | 
			
		||||
                <th rowspan="3">ชื่อ-สกุล</th>
 | 
			
		||||
                <th rowspan="3">ตำแหน่ง</th>
 | 
			
		||||
                <th rowspan="3">หมวดหมู่</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -38,8 +38,8 @@
 | 
			
		|||
        {{#each lines }}
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td>{{no}}</th>
 | 
			
		||||
                    <td>{{number}}</th>
 | 
			
		||||
                    {{#ifeq ../staff_type "nurse"}}
 | 
			
		||||
                        <td>{{number}}</th>
 | 
			
		||||
                        <td>
 | 
			
		||||
                            {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}
 | 
			
		||||
                        </td>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue