include rd shop in report_medical summary/details
parent
b9f8fbdd46
commit
5b75d5fda0
|
@ -30,7 +30,7 @@ class ReportMedicalDetail(Model):
|
||||||
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
|
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
|
||||||
date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
|
date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
|
||||||
categ_id=defaults.get('categ_id',None)
|
categ_id=defaults.get('categ_id',None)
|
||||||
report_type=defaults.get('report_type',"completed")
|
report_type=defaults.get('report_type') or "completed"
|
||||||
if not categ_id:
|
if not categ_id:
|
||||||
categ_ids=get_model("product.categ").search([['code','=','MDC']])
|
categ_ids=get_model("product.categ").search([['code','=','MDC']])
|
||||||
if categ_ids:
|
if categ_ids:
|
||||||
|
@ -67,7 +67,6 @@ class ReportMedicalDetail(Model):
|
||||||
'product_id': product_id,
|
'product_id': product_id,
|
||||||
'report_type': report_type,
|
'report_type': report_type,
|
||||||
}
|
}
|
||||||
print('report_type ', report_type)
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_report_data(self,ids,context={}):
|
def get_report_data(self,ids,context={}):
|
||||||
|
@ -76,7 +75,6 @@ class ReportMedicalDetail(Model):
|
||||||
defaults=self.default_get(context=context)
|
defaults=self.default_get(context=context)
|
||||||
time_start=defaults.get("date_from")
|
time_start=defaults.get("date_from")
|
||||||
time_stop=defaults.get("date_to")
|
time_stop=defaults.get("date_to")
|
||||||
prod_categ_id=defaults.get("prod_categ_id")
|
|
||||||
branch_id=defaults.get("branch_id")
|
branch_id=defaults.get("branch_id")
|
||||||
department_id=defaults.get("department_id")
|
department_id=defaults.get("department_id")
|
||||||
product_id=defaults.get('product_id')
|
product_id=defaults.get('product_id')
|
||||||
|
@ -84,7 +82,6 @@ class ReportMedicalDetail(Model):
|
||||||
report_type=defaults.get('report_type','completed')
|
report_type=defaults.get('report_type','completed')
|
||||||
if ids:
|
if ids:
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
prod_categ_id=obj.prod_categ_id.id
|
|
||||||
product_id=obj.product_id.id
|
product_id=obj.product_id.id
|
||||||
types=obj.types
|
types=obj.types
|
||||||
branch_id=obj.branch_id.id
|
branch_id=obj.branch_id.id
|
||||||
|
@ -97,10 +94,16 @@ class ReportMedicalDetail(Model):
|
||||||
['hd_case_id.date','>=',time_start],
|
['hd_case_id.date','>=',time_start],
|
||||||
['hd_case_id.date','<=',time_stop],
|
['hd_case_id.date','<=',time_stop],
|
||||||
]
|
]
|
||||||
|
shop_dom=[
|
||||||
|
['shop_id.date','>=',time_start],
|
||||||
|
['shop_id.date','<=',time_stop],
|
||||||
|
]
|
||||||
if branch_id:
|
if branch_id:
|
||||||
dom.append(['hd_case_id.branch_id','=',branch_id])
|
dom.append(['hd_case_id.branch_id','=',branch_id])
|
||||||
|
shop_dom.append(['shop_id.branch_id','=',branch_id])
|
||||||
if department_id:
|
if department_id:
|
||||||
dom.append(['hd_case_id.department_id','=',department_id])
|
dom.append(['hd_case_id.department_id','=',department_id])
|
||||||
|
shop_dom.append(['shop_id.department_id','=',department_id])
|
||||||
st=get_model("clinic.setting").browse(1)
|
st=get_model("clinic.setting").browse(1)
|
||||||
ct_ids=[]
|
ct_ids=[]
|
||||||
for categ in st.product_categ_view:
|
for categ in st.product_categ_view:
|
||||||
|
@ -137,6 +140,26 @@ class ReportMedicalDetail(Model):
|
||||||
'hname': hdcase.number,
|
'hname': hdcase.number,
|
||||||
})
|
})
|
||||||
total_qty+=qty
|
total_qty+=qty
|
||||||
|
|
||||||
|
for line in get_model("clinic.shop.line").search_browse(shop_dom):
|
||||||
|
shop=line.shop_id
|
||||||
|
patient=shop.patient_id
|
||||||
|
department=shop.department_id
|
||||||
|
qty=line.qty or 0
|
||||||
|
lines.append({
|
||||||
|
'date': shop.date or '',
|
||||||
|
'tname': patient.type_id.name or '',
|
||||||
|
'pname': patient.name or '',
|
||||||
|
'qty': qty,
|
||||||
|
'cname': 'RD Shop',
|
||||||
|
'cseq': 999,
|
||||||
|
'dpt_name': department.name,
|
||||||
|
'hid': shop.id,
|
||||||
|
'hname': shop.number,
|
||||||
|
'is_shop': True,
|
||||||
|
})
|
||||||
|
total_qty+=qty
|
||||||
|
|
||||||
sub_name=''
|
sub_name=''
|
||||||
if department_id:
|
if department_id:
|
||||||
dpt=get_model("clinic.department").browse(department_id)
|
dpt=get_model("clinic.department").browse(department_id)
|
||||||
|
@ -146,8 +169,9 @@ class ReportMedicalDetail(Model):
|
||||||
sub_name="(%s)" % branch.name or ""
|
sub_name="(%s)" % branch.name or ""
|
||||||
company_id=get_active_company()
|
company_id=get_active_company()
|
||||||
company=get_model("company").browse(company_id)
|
company=get_model("company").browse(company_id)
|
||||||
|
lines=sorted(lines,key=lambda x: (x['date'],x['cseq']))
|
||||||
no=1
|
no=1
|
||||||
for line in sorted(lines,key=lambda x: (x['date'],x['cseq'])):
|
for line in lines:
|
||||||
line['no']=no
|
line['no']=no
|
||||||
no+=1
|
no+=1
|
||||||
data={
|
data={
|
||||||
|
|
|
@ -79,11 +79,16 @@ class ReportMedicalSummary(Model):
|
||||||
time_start=obj.date_from
|
time_start=obj.date_from
|
||||||
time_stop=obj.date_to
|
time_stop=obj.date_to
|
||||||
report_type=obj.report_type or "completed"
|
report_type=obj.report_type or "completed"
|
||||||
print('report_type ---> ', report_type)
|
|
||||||
products={}
|
products={}
|
||||||
patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")}
|
patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")}
|
||||||
|
|
||||||
dom=[]
|
dom=[]
|
||||||
|
shop_dom=[
|
||||||
|
['date','>=',time_start],
|
||||||
|
['date','<=',time_stop],
|
||||||
|
['department_id','=',department_id],
|
||||||
|
['branch_id','=',branch_id],
|
||||||
|
]
|
||||||
dom.append(['type','=','stock'])
|
dom.append(['type','=','stock'])
|
||||||
dom.append(['report_visible','=',True])
|
dom.append(['report_visible','=',True])
|
||||||
st=get_model("clinic.setting").browse(1)
|
st=get_model("clinic.setting").browse(1)
|
||||||
|
@ -136,6 +141,15 @@ class ReportMedicalSummary(Model):
|
||||||
else:
|
else:
|
||||||
products[prod_code][patient_type_id]['qty']+=line.qty
|
products[prod_code][patient_type_id]['qty']+=line.qty
|
||||||
|
|
||||||
|
# add qty from rd shop
|
||||||
|
for shop in get_model("clinic.shop").search_browse(shop_dom):
|
||||||
|
for line in shop.lines:
|
||||||
|
prod=line.product_id
|
||||||
|
categ=line.categ_id
|
||||||
|
if categ and categ.id not in list(categ_ids):
|
||||||
|
continue
|
||||||
|
products[prod.code][themself_id]['qty']+=line.qty
|
||||||
|
|
||||||
lines=[]
|
lines=[]
|
||||||
limit_char=25
|
limit_char=25
|
||||||
titles=[{'name': 'ชื่อยา'}]
|
titles=[{'name': 'ชื่อยา'}]
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>HDCase#</th>
|
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
|
<th>Cycle</th>
|
||||||
|
<th>Number</th>
|
||||||
<th>Patient</th>
|
<th>Patient</th>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th>Cycle</th>
|
|
||||||
<th>Department</th>
|
<th>Department</th>
|
||||||
<th>Qty</th>
|
<th>Qty</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -20,13 +20,17 @@
|
||||||
{{#each lines}}
|
{{#each lines}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{no}}</td>
|
<td>{{no}}</td>
|
||||||
<td>
|
|
||||||
{{view "link" string=hname action="clinic_hd_case" action_options="mode=form" active_id=hid}}
|
|
||||||
</td>
|
|
||||||
<td>{{date}}</td>
|
<td>{{date}}</td>
|
||||||
|
<td>{{cname}}</td>
|
||||||
|
<td>
|
||||||
|
{{#if is_shop}}
|
||||||
|
{{view "link" string=hname action="clinic_shop" action_options="mode=form" active_id=hid}}
|
||||||
|
{{else}}
|
||||||
|
{{view "link" string=hname action="clinic_hd_case" action_options="mode=form" active_id=hid}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
<td>{{pname}}</td>
|
<td>{{pname}}</td>
|
||||||
<td>{{tname}}</td>
|
<td>{{tname}}</td>
|
||||||
<td>{{cname}}</td>
|
|
||||||
<td>{{dpt_name}}</td>
|
<td>{{dpt_name}}</td>
|
||||||
<td>{{qty}}</td>
|
<td>{{qty}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</td>
|
</td>
|
||||||
{{#each sub_lines}}
|
{{#each sub_lines}}
|
||||||
<td style="text-align:center">
|
<td style="text-align:center">
|
||||||
<a href="/ui#name=clinic_report_medical_detail&defaults.date_from={{time_start}}&defaults.date_to={{time_stop}}&defaults.types={{types}}&defaults.product_id={{product_id}}&defaults.product_categ_id={{product_categ_id}}">{{qty}} </a>
|
<a href="/ui#name=clinic_report_medical_detail&defaults.report_type={{report_type}}&defaults.date_from={{time_start}}&defaults.date_to={{time_stop}}&defaults.types={{types}}&defaults.product_id={{product_id}}&defaults.product_categ_id={{product_categ_id}}">{{qty}} </a>
|
||||||
</td>
|
</td>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue