report medical summary: set default product category by EPO
parent
4583f43d0b
commit
157f76bf05
|
@ -2,4 +2,5 @@
|
|||
<field name="date" span="3" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="3"/>
|
||||
<field name="date_to" span="3"/>
|
||||
<field name="prod_categ_id" span="3"/>
|
||||
</form>
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
from . import clinic_setting
|
||||
#from . import import_pks
|
||||
from . import import_uc
|
||||
from . import import_ar
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
from netforce.model import get_model
|
||||
from netforce import migration
|
||||
|
||||
class Migration(migration.Migration):
|
||||
_name="import.ar"
|
||||
_version="2.10.0"
|
||||
|
||||
def migrate(self):
|
||||
cbv_id=24
|
||||
cbv=get_model("conv.bal").browse(cbv_id)
|
||||
cbv.write({
|
||||
'file': '',
|
||||
})
|
||||
print("import acc file running ...")
|
||||
get_model("conv.bal").import_acc_file([cbv.id],context={})
|
||||
print("import sale file running ...")
|
||||
cbv.write({
|
||||
'file': '',
|
||||
})
|
||||
get_model("conv.bal").import_sale_file([cbv.id],context={})
|
||||
print("Done! ", cbv.id, cbv.file)
|
||||
return True
|
||||
|
||||
Migration.register()
|
|
@ -61,21 +61,20 @@ class ReportLaborCostSummary(Model):
|
|||
staff=line.staff_id
|
||||
if not staffs.get(staff.name):
|
||||
staffs[staff.name]={
|
||||
'staff_id': staff.id,
|
||||
dpt.name: {
|
||||
'type': staff.type,
|
||||
'amt': amt,
|
||||
'amt': 0,
|
||||
},
|
||||
}
|
||||
else:
|
||||
#XXX bug
|
||||
if not staffs[staff.name].get(dpt.name):
|
||||
staffs[staff.name][dpt.name]={
|
||||
'type': staff.type,
|
||||
'amt': amt,
|
||||
if not staffs[staff.name].get(dpt.name):
|
||||
staffs[staff.name]={
|
||||
'staff_id': staff.id,
|
||||
dpt.name: {
|
||||
'amt':amt,
|
||||
}
|
||||
#if staffs.get(staff.name):
|
||||
#if staffs[staff.name].get(dpt.name):
|
||||
#staffs[staff.name][dpt.name]['amt']+=amt
|
||||
}
|
||||
staffs[staff.name][dpt.name]['amt']+=amt
|
||||
|
||||
lines=[]
|
||||
dpts=get_model("clinic.department").search_read([],['name'])
|
||||
|
@ -86,9 +85,11 @@ class ReportLaborCostSummary(Model):
|
|||
snames=sorted(staffs.keys()) #sort by staff name
|
||||
for sname in snames:
|
||||
vals=staffs[sname]
|
||||
print(">> ", vals.get('staff_name'), ' ', sname)
|
||||
lvals={
|
||||
'no': no,
|
||||
'staff_name': sname,
|
||||
'staff_id': vals.get('staff_id'),
|
||||
}
|
||||
total=0
|
||||
lvals['sub_lines']=[]
|
||||
|
|
|
@ -14,6 +14,7 @@ class ReportMedicalSummary(Model):
|
|||
"date": fields.Date("Month", required=True),
|
||||
"date_from": fields.Date("From", required=True),
|
||||
"date_to": fields.Date("To", required=True),
|
||||
"prod_categ_id": fields.Many2One("product.categ","Category"),
|
||||
}
|
||||
|
||||
def _get_date_from(self,context={}):
|
||||
|
@ -24,11 +25,19 @@ class ReportMedicalSummary(Model):
|
|||
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
return "%s-%s-%s"%(year,month,total_day)
|
||||
|
||||
def _get_prod_categ(self,context={}):
|
||||
categ_id=None
|
||||
ids=get_model("product.categ").search([['code','=','EPO']])
|
||||
if ids:
|
||||
categ_id=ids[0]
|
||||
return categ_id
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'date_from': _get_date_from,
|
||||
'date_to': _get_date_to,
|
||||
'prod_categ_id': _get_prod_categ,
|
||||
}
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
|
@ -43,21 +52,27 @@ class ReportMedicalSummary(Model):
|
|||
weekday, total_day=monthrange(int(year), int(month))
|
||||
time_start='%s-%s-01'%(year,str(month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
|
||||
|
||||
|
||||
prod_categ_id=None
|
||||
prod_ids=get_model("product.categ").search([['code','=','EPO']])
|
||||
if prod_ids:
|
||||
prod_categ_id=prod_ids[0]
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
prod_categ_id=obj.prod_categ_id.id
|
||||
month=obj.date_from.split("-")[1]
|
||||
time_start=obj.date_from
|
||||
time_stop=obj.date_to
|
||||
|
||||
dom=[]
|
||||
dom.append(['time_start','>=','%s 00:00:00'%time_start])
|
||||
dom.append(['time_stop','<=','%s 23:59:59'%time_stop])
|
||||
|
||||
products={}
|
||||
patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")}
|
||||
print(patient_types)
|
||||
for prod in get_model("product").search_browse([['type','=','stock']]):
|
||||
|
||||
dom=[]
|
||||
dom.append(['type','=','stock'])
|
||||
if prod_categ_id:
|
||||
dom.append(['categ_id','=',prod_categ_id])
|
||||
print('dom ', dom)
|
||||
for prod in get_model("product").search_browse(dom):
|
||||
prod_code=prod.code or ""
|
||||
products[prod_code]={}
|
||||
for patient_type_id,type_name in patient_types.items():
|
||||
|
@ -68,16 +83,20 @@ class ReportMedicalSummary(Model):
|
|||
'prod_id': prod.id,
|
||||
}
|
||||
|
||||
dom=[]
|
||||
dom.append(['time_start','>=','%s 00:00:00'%time_start])
|
||||
dom.append(['time_stop','<=','%s 23:59:59'%time_stop])
|
||||
for hd_case in get_model('clinic.hd.case').search_browse(dom):
|
||||
patient_type_id=hd_case.patient_id.type_id.id
|
||||
for line in hd_case.lines:
|
||||
prod=line.product_id
|
||||
prod_code=prod.code or ""
|
||||
#XXX
|
||||
if not prod_code or not prod.active:
|
||||
continue
|
||||
if line.type=='fee' or prod.type=='service':
|
||||
continue
|
||||
if prod_categ_id and prod_categ_id != prod.categ_id.id:
|
||||
continue
|
||||
products[prod_code][patient_type_id]['qty']+=line.qty
|
||||
|
||||
lines=[]
|
||||
|
|
|
@ -108,12 +108,16 @@ class ClinicSetting(Model):
|
|||
if user_id !=1:
|
||||
print("Only admin!!")
|
||||
return
|
||||
for pt in get_model("clinic.patient").search_browse([]):
|
||||
hn=''.join(x for x in (pt.number or "") if x.isdigit())
|
||||
pt.write({
|
||||
'hn_no': hn,
|
||||
})
|
||||
print("Done! ")
|
||||
cbv_id=None
|
||||
for cbv in get_model("conv.bal").search_browse([]):
|
||||
if cbv.file:
|
||||
cbv_id=cbv.id
|
||||
print(get_file_path(cbv.file))
|
||||
cbv=get_model("conv.bal").browse(cbv_id)
|
||||
#if cbv:
|
||||
#print("running ...")
|
||||
#get_model("conv.bal").import_sale_file([cbv.id],context=context)
|
||||
print("Done! ", cbv.id)
|
||||
|
||||
def reset_last_import(self,ids,context={}):
|
||||
res=get_model("clinic.report.payment.matching").search_read([],['date'],order="date desc")
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
{{#each lines }}
|
||||
<tr>
|
||||
<td>{{no}}</th>
|
||||
<td>{{staff_name}}</td>
|
||||
<td>
|
||||
{{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}
|
||||
</td>
|
||||
{{#each sub_lines}}
|
||||
<td style="text-align:right;">{{currency amt zero=""}}</td>
|
||||
{{/each}}
|
||||
|
|
Loading…
Reference in New Issue