prevent to duplicate enter account product/patient
							parent
							
								
									b7bf99819c
								
							
						
					
					
						commit
						f8521a2e16
					
				| 
						 | 
				
			
			@ -11,7 +11,7 @@
 | 
			
		|||
            <header string="REPORTS"/>
 | 
			
		||||
            <item string="HD Case Expense" action="clinic_report_account_hd_case_summary"/>
 | 
			
		||||
            <item string="RD Shop Expense" action="clinic_report_account_shop"/>
 | 
			
		||||
            <item string="Labor Cost" action="clinic_report_labor_cost"/>
 | 
			
		||||
            <item string="Labor Cost Overview" action="clinic_report_labor_cost"/>
 | 
			
		||||
            <!--<item string="Labor Cost Summary" action="clinic_report_labor_cost_summary"/>-->
 | 
			
		||||
            <!--<item string="Labor Cost Detail" action="clinic_report_labor_cost_detail"/>-->
 | 
			
		||||
            <!--<item string="Labor Cost Sub Detail" action="clinic_report_labor_cost_sub_detail"/>-->
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
    <field name="staff_id" domain='[["type","=",staff_type]]' span="2"/>
 | 
			
		||||
    <field name="branch_id" onchange="onchange_branch" span="2"/>
 | 
			
		||||
    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
 | 
			
		||||
    <field name="categ_id" span="2"/>
 | 
			
		||||
    <field name="categ_id" domain='[["type","=","nurse"]]' span="2"/>
 | 
			
		||||
    <field name="level_id" span="2"/>
 | 
			
		||||
    <field name="only_value" span="2"/>
 | 
			
		||||
</form>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,10 @@ class LaborCost(Model):
 | 
			
		|||
            total_stcost=0.0
 | 
			
		||||
            for line in obj.staff_lines:
 | 
			
		||||
                total_stcost+=line.amount or 0.0
 | 
			
		||||
            #XXX
 | 
			
		||||
            total_ncost=round(total_ncost,0)
 | 
			
		||||
            total_dcost=round(total_dcost,0)
 | 
			
		||||
            total_stcost=round(total_stcost,0)
 | 
			
		||||
            total_formular=round(total_formular,0)
 | 
			
		||||
            total=total_ncost+total_dcost+total_stcost
 | 
			
		||||
            res[obj.id]={
 | 
			
		||||
                'var_pt': total_case,
 | 
			
		||||
| 
						 | 
				
			
			@ -69,10 +72,10 @@ class LaborCost(Model):
 | 
			
		|||
                'var_fml3': '(%s%s)/%s'%(var_ptx,total_bstr,total_a),
 | 
			
		||||
                'var_x': round(var_x,2),
 | 
			
		||||
                'total': total,
 | 
			
		||||
                'total_formular': round(total_formular,0),
 | 
			
		||||
                'total_ncost': round(total_ncost,0),
 | 
			
		||||
                'total_formular': total_formular,
 | 
			
		||||
                'total_ncost': total_ncost,
 | 
			
		||||
                'total_nqty': total_nqty,
 | 
			
		||||
                'total_dcost': round(total_dcost,0),
 | 
			
		||||
                'total_dcost': total_dcost,
 | 
			
		||||
                'total_dqty': total_dqty,
 | 
			
		||||
                'total_stcost': total_stcost,
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,7 +99,6 @@ class ReportLaborCostSummary(Model):
 | 
			
		|||
        citems={}
 | 
			
		||||
        print('dom ', dom)
 | 
			
		||||
        total_hdcase=0
 | 
			
		||||
        x=set()
 | 
			
		||||
        for line in get_model("clinic.labor.cost.line").search_browse(dom):
 | 
			
		||||
            lcost=line.labor_cost_id
 | 
			
		||||
            citem=lcost.cycle_item_id
 | 
			
		||||
| 
						 | 
				
			
			@ -245,6 +244,7 @@ class ReportLaborCostSummary(Model):
 | 
			
		|||
            'total_lines': total_lines,
 | 
			
		||||
            'total_hdcase': total_hdcase or 0,
 | 
			
		||||
            'total_cost': round(total_cost,0) or 0,
 | 
			
		||||
            'staff_type': staff_type,
 | 
			
		||||
        }
 | 
			
		||||
        return data
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,8 +20,16 @@ DAYS={
 | 
			
		|||
class ClinicSetting(Model):
 | 
			
		||||
    _name="clinic.setting"
 | 
			
		||||
    _string="Setting"
 | 
			
		||||
    _field_name="var_k"
 | 
			
		||||
    
 | 
			
		||||
    def _get_name(self,ids,context={}):
 | 
			
		||||
        res={}
 | 
			
		||||
        for obj in self.browse(ids):
 | 
			
		||||
            res[obj.id]='xxx'
 | 
			
		||||
        return res
 | 
			
		||||
 | 
			
		||||
    _fields={
 | 
			
		||||
        'name': fields.Char("Name", function="_get_name"),
 | 
			
		||||
        "var_k": fields.Float("K"),
 | 
			
		||||
        'signature': fields.File("Signature"),
 | 
			
		||||
        'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
 | 
			
		||||
| 
						 | 
				
			
			@ -152,11 +160,16 @@ class ClinicSetting(Model):
 | 
			
		|||
        if user_id !=1:
 | 
			
		||||
            print("Only admin!!")
 | 
			
		||||
            return
 | 
			
		||||
        path='/tmp/test'
 | 
			
		||||
        self.update_pcycle(path,['ls1.csv','ls2.csv','ls3.csv'])
 | 
			
		||||
        #path='/tmp/test'
 | 
			
		||||
        #self.update_pcycle(path,['ls1.csv','ls2.csv','ls3.csv'])
 | 
			
		||||
        ###TODO remove douplicate patient
 | 
			
		||||
        ###TODO remove douplicate staff
 | 
			
		||||
        ###TODO remove douplicate visit
 | 
			
		||||
        obj=self.browse(ids)[0]
 | 
			
		||||
        for ap_line in obj.account_patients:
 | 
			
		||||
            pt=ap_line.patient_id
 | 
			
		||||
            if not pt:
 | 
			
		||||
                ap_line.delete()
 | 
			
		||||
        print("Done!")
 | 
			
		||||
 | 
			
		||||
    def multi_department(self,ids,context={}):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,9 +7,9 @@ class SettingAccountPatient(Model):
 | 
			
		|||
 | 
			
		||||
    _fields={
 | 
			
		||||
        "setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"),
 | 
			
		||||
        "patient_id": fields.Many2One("clinic.patient","Patient",domain=[["state","=","admit"]], search=True),
 | 
			
		||||
        'partner_id': fields.Many2One("partner","Contact", search=True),
 | 
			
		||||
        'type_id': fields.Many2One("clinic.patient.type","Type", search=True),
 | 
			
		||||
        "patient_id": fields.Many2One("clinic.patient","Patient",domain=[["state","=","admit"]], search=True,required=True),
 | 
			
		||||
        'partner_id': fields.Many2One("partner","Contact", search=True,required=True),
 | 
			
		||||
        'type_id': fields.Many2One("clinic.patient.type","Type", search=True,required=True),
 | 
			
		||||
        'hn': fields.Char("HN", search=True),
 | 
			
		||||
        'card_no': fields.Char("ID Card",size=13, search=True),
 | 
			
		||||
        'company_id': fields.Many2One("company","Company"),
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ class SettingAccountPatient(Model):
 | 
			
		|||
        'setting_id': 1,
 | 
			
		||||
        "company_id": lambda *a: get_active_company(),
 | 
			
		||||
    }
 | 
			
		||||
    _sql_constraints=("clinic_setting_acc_pt_key_uniq","unique(patient_id,partner_id,type_id,hn,card_no)","account patient should be unique"),
 | 
			
		||||
    _order="type_id,patient_id"
 | 
			
		||||
 | 
			
		||||
SettingAccountPatient.register()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,20 +8,20 @@ class SettingAccountProduct(Model):
 | 
			
		|||
 | 
			
		||||
    _fields={
 | 
			
		||||
        "setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"),
 | 
			
		||||
        "patient_type_id": fields.Many2One("clinic.patient.type","Patient Type",search=True),
 | 
			
		||||
        'categ_id': fields.Many2One("product.categ","Category",search=True),
 | 
			
		||||
        "product_id": fields.Many2One("product","Product",search=True),
 | 
			
		||||
        "patient_type_id": fields.Many2One("clinic.patient.type","Patient Type",search=True,required=True),
 | 
			
		||||
        'categ_id': fields.Many2One("product.categ","Category",search=True,required=True),
 | 
			
		||||
        "product_id": fields.Many2One("product","Product",search=True,required=True),
 | 
			
		||||
        "ar_credit_id": fields.Many2One("account.account","Income Credit",multi_company=True,search=True),
 | 
			
		||||
        "ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True,search=True),
 | 
			
		||||
        "type": fields.Selection([("cash","Cash"),("credit","Credit")],"Type",search=True,required=True),
 | 
			
		||||
        'company_id': fields.Many2One("company","Company"),
 | 
			
		||||
        "type": fields.Selection([("cash","Cash"),("credit","Credit")],"Type",search=True),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _defaults={
 | 
			
		||||
        "company_id": lambda *a: get_active_company(),
 | 
			
		||||
        'setting_id': 1,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _sql_constraints=("clinic_setting_acc_prod_key_uniq","unique(patient_type_id,categ_id,product_id,ar_credit_id,ar_debit_id,type)","account product should be unique"),
 | 
			
		||||
    _order="patient_type_id"
 | 
			
		||||
 | 
			
		||||
SettingAccountProduct.register()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@
 | 
			
		|||
<table class="table table-condensed table-striped">
 | 
			
		||||
    <thead>
 | 
			
		||||
        <th>ชั้น</th>
 | 
			
		||||
        <th style="text-align:right">จำนวน HD Case</th>
 | 
			
		||||
        <th style="text-align:right">รวม</th>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody>
 | 
			
		||||
        {{#each lines }}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,9 +20,13 @@
 | 
			
		|||
        <tr>
 | 
			
		||||
            <th rowspan="2">#</th>
 | 
			
		||||
            <th rowspan="2">รหัส</th>
 | 
			
		||||
            {{#ifeq staff_type "nurse"}}
 | 
			
		||||
                <th rowspan="2">ชื่อ-สกุล</th>
 | 
			
		||||
                <th rowspan="2">ตำแหน่ง</th>
 | 
			
		||||
                <th rowspan="2">หมวดหมู่</th>
 | 
			
		||||
            {{else}}
 | 
			
		||||
                <th rowspan="2" colspan="3">ชื่อ-สกุล</th>
 | 
			
		||||
            {{/ifeq}}
 | 
			
		||||
            {{#each dpts}}
 | 
			
		||||
                <th style="text-align:right">{{name}}</th>
 | 
			
		||||
            {{/each}}
 | 
			
		||||
| 
						 | 
				
			
			@ -35,11 +39,17 @@
 | 
			
		|||
                <tr>
 | 
			
		||||
                    <td>{{no}}</th>
 | 
			
		||||
                    <td>{{number}}</th>
 | 
			
		||||
                    {{#ifeq ../staff_type "nurse"}}
 | 
			
		||||
                        <td>
 | 
			
		||||
                            {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}
 | 
			
		||||
                        </td>
 | 
			
		||||
                        <td>{{staff_level}}</th>
 | 
			
		||||
                        <td>{{categ_name}}</th>
 | 
			
		||||
                    {{else}}
 | 
			
		||||
                        <td colspan="3">
 | 
			
		||||
                            {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}
 | 
			
		||||
                        </td>
 | 
			
		||||
                    {{/ifeq}}
 | 
			
		||||
                    {{#each sub_lines}}
 | 
			
		||||
                        <td style="text-align:right;">
 | 
			
		||||
                            <a href="#name=clinic_report_labor_cost_detail&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.staff_type={{../staff_type}}&defaults.staff_id={{../staff_id}}&defaults.department_id={{dpt_id}}">{{currency amt zero=""}}</a>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue