improve report claim expense

conv_bal
watcha.h@almacom.co.th 2015-03-30 17:47:00 +07:00
parent 92849ca6e7
commit 5cb027d9c3
3 changed files with 17 additions and 14 deletions

View File

@ -5,6 +5,7 @@
<field name="branch_id" onchange="onchange_branch" span="3"/> <field name="branch_id" onchange="onchange_branch" span="3"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/> <field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
<field name="ptype_id" span="2"/> <field name="ptype_id" span="2"/>
<field name="walkin" span="2"/>
<field name="reimbursable" span="2"/> <field name="reimbursable" span="2"/>
<field name="cycle_id" span="2"/> <field name="cycle_id" span="2"/>
<field name="product_id" span="2"/> <field name="product_id" span="2"/>

View File

@ -37,7 +37,7 @@ class HDCaseStaff(Model):
_defaults={ _defaults={
'type': 'doctor', 'type': 'doctor',
'priop': 'second', 'priop': 'owner',
} }
HDCaseStaff.register() HDCaseStaff.register()

View File

@ -17,6 +17,7 @@ class ReportAccountHDCaseSummary(Model):
'department_id': fields.Many2One("clinic.department","Departments"), 'department_id': fields.Many2One("clinic.department","Departments"),
'ptype_id': fields.Many2One("clinic.patient.type","Patient Type"), 'ptype_id': fields.Many2One("clinic.patient.type","Patient Type"),
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],'Claim'), 'reimbursable': fields.Selection([['yes','Yes'],['no','No']],'Claim'),
'walkin': fields.Selection([['yes','Yes'],['no','No']],'Walkin'),
'cycle_id': fields.Many2One("clinic.cycle","Cycle"), 'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
'product_id': fields.Many2One("product","Product"), 'product_id': fields.Many2One("product","Product"),
} }
@ -72,6 +73,7 @@ class ReportAccountHDCaseSummary(Model):
department_id=defaults.get("department_id") department_id=defaults.get("department_id")
reimbursable=defaults.get('reimbursable','yes') reimbursable=defaults.get('reimbursable','yes')
product_id=defaults.get('product_id') product_id=defaults.get('product_id')
walkin=defaults.get('walkin')
ptype_id=None ptype_id=None
cycle_id=None cycle_id=None
if ids: if ids:
@ -85,12 +87,14 @@ class ReportAccountHDCaseSummary(Model):
cycle_id=obj.cycle_id.id cycle_id=obj.cycle_id.id
reimbursable=obj.reimbursable or "" reimbursable=obj.reimbursable or ""
product_id=obj.product_id.id product_id=obj.product_id.id
walkin=obj.walkin
dom=[ dom=[
['hd_case_id.date','>=', date_from], ['hd_case_id.date','>=', date_from],
['hd_case_id.date','<=', date_to], ['hd_case_id.date','<=', date_to],
['hd_case_id.patient_id.walkin','=','no'],
['hd_case_id.state','in',['completed','waiting_payment','paid']], ['hd_case_id.state','in',['completed','waiting_payment','paid']],
] ]
if walkin:
dom.append(['hd_case_id.patient_id.walkin','=',walkin])
if ptype_id: if ptype_id:
dom.append(['hd_case_id.patient_type_id','=',ptype_id]) dom.append(['hd_case_id.patient_type_id','=',ptype_id])
if branch_id: if branch_id:
@ -180,7 +184,7 @@ class ReportAccountHDCaseSummary(Model):
'mdc_name': hdcase.mdc_name, 'mdc_name': hdcase.mdc_name,
'dlz_name': hdcase.dlz_name, 'dlz_name': hdcase.dlz_name,
'dlz_id': hdcase.dlz_id and hdcase.dlz_id or 0, 'dlz_id': hdcase.dlz_id and hdcase.dlz_id or 0,
'dlz_price': hdcase.dlz_price or 1, 'dlz_price': hdcase.dlz_price,
'lab': hdcase.lab, 'lab': hdcase.lab,
'misc': hdcase.misc, 'misc': hdcase.misc,
'inv_ref': inv_ref and inv_ref or "-", 'inv_ref': inv_ref and inv_ref or "-",
@ -207,18 +211,16 @@ class ReportAccountHDCaseSummary(Model):
lines=[] lines=[]
for hdnumber, vals in records.items(): for hdnumber, vals in records.items():
lines.append(vals) lines.append(vals)
print("#1 ", len(lines))
#get data from rd shop #get data from rd shop
if reimbursable=='no': #if reimbursable=='no':
ctx={ #ctx={
'date_from': date_from, #'date_from': date_from,
'date_to': date_to, #'date_to': date_to,
'branch_id': branch_id, #'branch_id': branch_id,
'department_id': department_id, #'department_id': department_id,
} #}
shop_lines=get_model('clinic.shop').get_shop_data(context=ctx)['records'] #shop_lines=get_model('clinic.shop').get_shop_data(context=ctx)['records']
lines+=shop_lines #lines+=shop_lines
print("#2 ", len(lines))
company_name=company.name or "" company_name=company.name or ""
if department_id: if department_id:
company_name+=' (%s)'%get_model('clinic.department').browse(department_id).name or "" company_name+=' (%s)'%get_model('clinic.department').browse(department_id).name or ""