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_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
|
||||
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:
|
||||
categ_ids=get_model("product.categ").search([['code','=','MDC']])
|
||||
if categ_ids:
|
||||
|
@ -67,7 +67,6 @@ class ReportMedicalDetail(Model):
|
|||
'product_id': product_id,
|
||||
'report_type': report_type,
|
||||
}
|
||||
print('report_type ', report_type)
|
||||
return res
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
|
@ -76,7 +75,6 @@ class ReportMedicalDetail(Model):
|
|||
defaults=self.default_get(context=context)
|
||||
time_start=defaults.get("date_from")
|
||||
time_stop=defaults.get("date_to")
|
||||
prod_categ_id=defaults.get("prod_categ_id")
|
||||
branch_id=defaults.get("branch_id")
|
||||
department_id=defaults.get("department_id")
|
||||
product_id=defaults.get('product_id')
|
||||
|
@ -84,7 +82,6 @@ class ReportMedicalDetail(Model):
|
|||
report_type=defaults.get('report_type','completed')
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
prod_categ_id=obj.prod_categ_id.id
|
||||
product_id=obj.product_id.id
|
||||
types=obj.types
|
||||
branch_id=obj.branch_id.id
|
||||
|
@ -97,10 +94,16 @@ class ReportMedicalDetail(Model):
|
|||
['hd_case_id.date','>=',time_start],
|
||||
['hd_case_id.date','<=',time_stop],
|
||||
]
|
||||
shop_dom=[
|
||||
['shop_id.date','>=',time_start],
|
||||
['shop_id.date','<=',time_stop],
|
||||
]
|
||||
if branch_id:
|
||||
dom.append(['hd_case_id.branch_id','=',branch_id])
|
||||
shop_dom.append(['shop_id.branch_id','=',branch_id])
|
||||
if 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)
|
||||
ct_ids=[]
|
||||
for categ in st.product_categ_view:
|
||||
|
@ -137,6 +140,26 @@ class ReportMedicalDetail(Model):
|
|||
'hname': hdcase.number,
|
||||
})
|
||||
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=''
|
||||
if department_id:
|
||||
dpt=get_model("clinic.department").browse(department_id)
|
||||
|
@ -146,8 +169,9 @@ class ReportMedicalDetail(Model):
|
|||
sub_name="(%s)" % branch.name or ""
|
||||
company_id=get_active_company()
|
||||
company=get_model("company").browse(company_id)
|
||||
lines=sorted(lines,key=lambda x: (x['date'],x['cseq']))
|
||||
no=1
|
||||
for line in sorted(lines,key=lambda x: (x['date'],x['cseq'])):
|
||||
for line in lines:
|
||||
line['no']=no
|
||||
no+=1
|
||||
data={
|
||||
|
|
|
@ -79,11 +79,16 @@ class ReportMedicalSummary(Model):
|
|||
time_start=obj.date_from
|
||||
time_stop=obj.date_to
|
||||
report_type=obj.report_type or "completed"
|
||||
print('report_type ---> ', report_type)
|
||||
products={}
|
||||
patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")}
|
||||
|
||||
dom=[]
|
||||
shop_dom=[
|
||||
['date','>=',time_start],
|
||||
['date','<=',time_stop],
|
||||
['department_id','=',department_id],
|
||||
['branch_id','=',branch_id],
|
||||
]
|
||||
dom.append(['type','=','stock'])
|
||||
dom.append(['report_visible','=',True])
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
|
@ -136,6 +141,15 @@ class ReportMedicalSummary(Model):
|
|||
else:
|
||||
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=[]
|
||||
limit_char=25
|
||||
titles=[{'name': 'ชื่อยา'}]
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>HDCase#</th>
|
||||
<th>Date</th>
|
||||
<th>Cycle</th>
|
||||
<th>Number</th>
|
||||
<th>Patient</th>
|
||||
<th>Type</th>
|
||||
<th>Cycle</th>
|
||||
<th>Department</th>
|
||||
<th>Qty</th>
|
||||
</tr>
|
||||
|
@ -20,13 +20,17 @@
|
|||
{{#each lines}}
|
||||
<tr>
|
||||
<td>{{no}}</td>
|
||||
<td>
|
||||
{{view "link" string=hname action="clinic_hd_case" action_options="mode=form" active_id=hid}}
|
||||
</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>{{tname}}</td>
|
||||
<td>{{cname}}</td>
|
||||
<td>{{dpt_name}}</td>
|
||||
<td>{{qty}}</td>
|
||||
</tr>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</td>
|
||||
{{#each sub_lines}}
|
||||
<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>
|
||||
{{/each}}
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue