improve
parent
2be7e0c34f
commit
16461ae34d
|
@ -2,5 +2,10 @@
|
|||
<field name="string">Staff Rotation</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.staff.rotation</field>
|
||||
<field name="tabs">[
|
||||
["All",[]],
|
||||
["Draft",[["state","=","draft"]]],
|
||||
["Approved",[["state","=","approved"]]]
|
||||
]</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
||||
|
|
|
@ -5,12 +5,10 @@
|
|||
<item string="Doctors" action="clinic_staff" action_options="tab_no=3"/>
|
||||
<item string="Nurses" action="clinic_staff" action_options="tab_no=4"/>
|
||||
<divider/>
|
||||
<header string="ROTATION"/>
|
||||
<item string="Staff Rotation" action="clinic_staff_rotate"/>
|
||||
<divider/>
|
||||
<header string="SETTINGS"/>
|
||||
<item string="Levels" action="clinic_staff_level"/>
|
||||
<item string="Categories" action="clinic_staff_categ"/>
|
||||
<item string="Staff Rotation" action="clinic_staff_rotate" perm="staff_rotation"/>
|
||||
</item>
|
||||
<item string="Patients" perm="clinic_patient">
|
||||
<item string="Patients" action="clinic_patient"/>
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<field name="first_name" required="1"/>
|
||||
<field name="last_name" required="1"/>
|
||||
<field name="name_eng"/>
|
||||
<field name="categ_id" domain="[['type','=',type]]"/>
|
||||
<!--<field name="name"/>-->
|
||||
<field name="company_id" invisible="1"/>
|
||||
<tabs>
|
||||
|
@ -47,6 +46,7 @@
|
|||
</tab>
|
||||
<tab string="Accounting" perm="staff_tab_account">
|
||||
<field name="partner_id" domain='[["is_staff","=","true"]]'/>
|
||||
<field name="categ_id" domain="[['type','=',type]]"/>
|
||||
<field name="level_id" domain="[['type','=',type]]"/>
|
||||
<field name="cycle_id"/>
|
||||
<field name="wage"/>
|
||||
|
@ -60,18 +60,18 @@
|
|||
<related>
|
||||
<field name="addresses"/>
|
||||
<field name="documents"/>
|
||||
<field name="rotations" nolabel="1">
|
||||
<list>
|
||||
<field name="level_id" domain="[['type','=',parent.type]]"/>
|
||||
<field name="from_company_id"/>
|
||||
<field name="to_company_id"/>
|
||||
<field name="hire_date"/>
|
||||
<field name="resign_date"/>
|
||||
<field name="max_cycle"/>
|
||||
<field name="wage"/>
|
||||
<field name="note"/>
|
||||
</list>
|
||||
</field>
|
||||
<!--<field name="rotations" nolabel="1">-->
|
||||
<!--<list>-->
|
||||
<!--<field name="level_id" domain="[['type','=',parent.type]]"/>-->
|
||||
<!--<field name="from_company_id"/>-->
|
||||
<!--<field name="to_company_id"/>-->
|
||||
<!--<field name="hire_date"/>-->
|
||||
<!--<field name="resign_date"/>-->
|
||||
<!--<field name="max_cycle"/>-->
|
||||
<!--<field name="wage"/>-->
|
||||
<!--<field name="note"/>-->
|
||||
<!--</list>-->
|
||||
<!--</field>-->
|
||||
<field name="hd_case_staffs" readonly="1" attrs='{"invisible":[["type","=","nurse"]]}'>
|
||||
<list colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]],"#70DB93":[["state","=","paid"]]}'>
|
||||
<field name="hd_case_id"/>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<field name="type"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="level_id"/>
|
||||
<field name="categ_id"/>
|
||||
<!--<field name="image" preview="1"/>-->
|
||||
<!--<field name="level_id"/>-->
|
||||
<!--<field name="categ_id"/>-->
|
||||
<field name="image" preview="1"/>
|
||||
</list>
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<form model="clinic.staff.rotation" show_company="1">
|
||||
<field name="staff_id" required="1"/>
|
||||
<form model="clinic.staff.rotation" attrs='{"readonly":[["state","=","approved"]]}' show_company="1">
|
||||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="To Draft" method="to_draft" states="approved"/>
|
||||
</button>
|
||||
</head>
|
||||
<field name="type" required="1"/>
|
||||
<field name="staff_id" domain='[["type","=",type]]' required="1"/>
|
||||
<field name="level_id"/>
|
||||
<field name="from_company_id"/>
|
||||
<field name="to_company_id"/>
|
||||
<field name="categ_id"/>
|
||||
<field name="hire_date"/>
|
||||
<field name="resign_date"/>
|
||||
<field name="wage"/>
|
||||
|
@ -10,4 +16,7 @@
|
|||
<field name="ot_per_cycle"/>
|
||||
<field name="note"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<foot>
|
||||
<button string="Approve" method="approve" type="success"/>
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<list model="clinic.staff.rotation">
|
||||
<field name="staff_id"/>
|
||||
<field name="type"/>
|
||||
<field name="level_id"/>
|
||||
<field name="from_company_id"/>
|
||||
<field name="to_company_id"/>
|
||||
<field name="hire_date"/>
|
||||
<field name="resign_date"/>
|
||||
<field name="categ_id"/>
|
||||
<field name="max_cycle"/>
|
||||
<field name="wage"/>
|
||||
<field name="note"/>
|
||||
<field name="ot_per_cycle"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
|
|
|
@ -9,216 +9,4 @@ class AccountInvoice(Model):
|
|||
'department_id': fields.Many2One("clinic.department","Department",search=True),
|
||||
}
|
||||
|
||||
#override netforce_account/account_invoice
|
||||
def post(self,ids,context={}):
|
||||
print("override post invoice")
|
||||
t0=time.time()
|
||||
settings=get_model("settings").browse(1)
|
||||
for obj in self.browse(ids):
|
||||
obj.check_related()
|
||||
if abs(obj.amount_total)<0.001:
|
||||
raise Exception("Invoice total is zero")
|
||||
partner=obj.partner_id
|
||||
if obj.type=="out":
|
||||
account_id=partner.account_receivable_id.id or settings.account_receivable_id.id
|
||||
if not account_id:
|
||||
raise Exception("Account receivable not found")
|
||||
elif obj.type=="in":
|
||||
account_id=partner.account_payable_id.id or settings.account_payable_id.id
|
||||
if not account_id:
|
||||
raise Exception("Account payable not found")
|
||||
sign=obj.type=="out" and 1 or -1
|
||||
if obj.inv_type=="credit":
|
||||
sign*=-1
|
||||
obj.write({"account_id": account_id})
|
||||
if obj.type=="out":
|
||||
desc="Sale; "+partner.name
|
||||
elif obj.type=="in":
|
||||
desc="Purchase; "+partner.name
|
||||
if obj.type=="out":
|
||||
journal_id=settings.sale_journal_id.id
|
||||
if obj.journal_id:
|
||||
journal_id=obj.journal_id.id
|
||||
if not journal_id:
|
||||
raise Exception("Sales journal not found")
|
||||
elif obj.type=="in":
|
||||
journal_id=settings.purchase_journal_id.id
|
||||
if obj.journal_id:
|
||||
journal_id=obj.journal_id.id
|
||||
if not journal_id:
|
||||
raise Exception("Purchases journal not found")
|
||||
if obj.type=="out":
|
||||
rate_type="sell"
|
||||
elif obj.type=="in":
|
||||
rate_type="buy"
|
||||
move_vals={
|
||||
"journal_id": journal_id,
|
||||
"number": obj.number,
|
||||
"date": obj.date,
|
||||
"ref": obj.ref,
|
||||
"narration": desc,
|
||||
"related_id": "account.invoice,%s"%obj.id,
|
||||
"company_id": obj.company_id.id,
|
||||
}
|
||||
lines=[]
|
||||
taxes={}
|
||||
tax_nos=[]
|
||||
t01=time.time()
|
||||
total_amt=0.0
|
||||
total_base=0.0
|
||||
total_tax=0.0
|
||||
hdcase=obj.related_id
|
||||
for line in obj.lines:
|
||||
cur_amt=get_model("currency").convert(line.amount,obj.currency_id.id,settings.currency_id.id,date=obj.date,rate_type=rate_type)
|
||||
total_amt+=cur_amt
|
||||
tax_id=line.tax_id
|
||||
if tax_id and obj.tax_type!="no_tax":
|
||||
base_amt=get_model("account.tax.rate").compute_base(tax_id,cur_amt,tax_type=obj.tax_type)
|
||||
tax_comps=get_model("account.tax.rate").compute_taxes(tax_id,base_amt,when="invoice")
|
||||
for comp_id,tax_amt in tax_comps.items():
|
||||
tax_vals=taxes.setdefault(comp_id,{"tax_amt":0,"base_amt":0})
|
||||
tax_vals["tax_amt"]+=tax_amt
|
||||
tax_vals["base_amt"]+=base_amt
|
||||
total_tax+=tax_amt
|
||||
else:
|
||||
base_amt=cur_amt
|
||||
total_base+=base_amt
|
||||
acc_id=line.account_id.id
|
||||
if not acc_id:
|
||||
raise Exception("Missing line account for invoice line '%s'"%line.description)
|
||||
amt=base_amt*sign
|
||||
line_vals={
|
||||
"description": line.description,
|
||||
"account_id": acc_id,
|
||||
"credit": amt>0 and amt or 0,
|
||||
"debit": amt<0 and -amt or 0,
|
||||
"track_id": line.track_id.id,
|
||||
"track2_id": line.track2_id.id,
|
||||
"partner_id": partner.id,
|
||||
}
|
||||
lines.append(line_vals)
|
||||
#XXX
|
||||
ar_debit=line.ar_debit_id
|
||||
if hdcase and ar_debit:
|
||||
amt=amt*-1
|
||||
line_vals={
|
||||
"description": line.description,
|
||||
"account_id": ar_debit.id,
|
||||
"credit": amt>0 and amt or 0,
|
||||
"debit": amt<0 and -amt or 0,
|
||||
"track_id": line.track_id.id,
|
||||
"track2_id": line.track2_id.id,
|
||||
"partner_id": partner.id,
|
||||
}
|
||||
lines.append(line_vals)
|
||||
|
||||
for comp_id,tax_vals in taxes.items():
|
||||
comp=get_model("account.tax.component").browse(comp_id)
|
||||
acc_id=comp.account_id.id
|
||||
if not acc_id:
|
||||
raise Exception("Missing account for tax component %s"%comp.name)
|
||||
amt=tax_vals["tax_amt"]*sign
|
||||
line_vals={
|
||||
"description": desc,
|
||||
"account_id": acc_id,
|
||||
"credit": amt>0 and amt or 0,
|
||||
"debit": amt<0 and -amt or 0,
|
||||
"tax_comp_id": comp_id,
|
||||
"tax_base": tax_vals["base_amt"],
|
||||
"partner_id": partner.id,
|
||||
"invoice_id": obj.id,
|
||||
}
|
||||
if comp.type=="vat":
|
||||
if obj.type=="out":
|
||||
if obj.tax_no:
|
||||
tax_no=obj.tax_no
|
||||
else:
|
||||
tax_no=self.gen_tax_no(exclude=tax_nos,context={"date":obj.date})
|
||||
tax_nos.append(tax_no)
|
||||
obj.write({"tax_no":tax_no})
|
||||
line_vals["tax_no"]=tax_no
|
||||
elif obj.type=="in":
|
||||
line_vals["tax_no"]=obj.tax_no
|
||||
lines.append(line_vals)
|
||||
if obj.tax_type=="tax_in":
|
||||
rounding=total_amt-(total_base+total_tax)
|
||||
if abs(rounding)>0.00499: # XXX
|
||||
amt=rounding*sign
|
||||
if not settings.rounding_account_id.id:
|
||||
raise Exception("Missing rounding account in financial settings")
|
||||
line_vals={
|
||||
"description": desc,
|
||||
"account_id": settings.rounding_account_id.id,
|
||||
"credit": amt>0 and amt or 0,
|
||||
"debit": amt<0 and -amt or 0,
|
||||
"partner_id": partner.id,
|
||||
"invoice_id": obj.id,
|
||||
}
|
||||
lines.append(line_vals)
|
||||
t02=time.time()
|
||||
dt01=(t02-t01)*1000
|
||||
print("post dt01",dt01)
|
||||
groups={}
|
||||
keys=["description","account_id","track_id","tax_comp_id","partner_id","invoice_id","reconcile_id"]
|
||||
for line in lines:
|
||||
key_val=tuple(line.get(k) for k in keys)
|
||||
if key_val in groups:
|
||||
group=groups[key_val]
|
||||
group["debit"]+=line["debit"]
|
||||
group["credit"]+=line["credit"]
|
||||
if line.get("tax_base"):
|
||||
if "tax_base" not in group:
|
||||
group["tax_base"]=0
|
||||
group["tax_base"]+=line["tax_base"]
|
||||
else:
|
||||
groups[key_val]=line.copy()
|
||||
group_lines=sorted(groups.values(),key=lambda l: (l["debit"],l["credit"]))
|
||||
for line in group_lines:
|
||||
amt=line["debit"]-line["credit"]
|
||||
amt=get_model("currency").round(settings.currency_id.id,amt)
|
||||
if amt>=0:
|
||||
line["debit"]=amt
|
||||
line["credit"]=0
|
||||
else:
|
||||
line["debit"]=0
|
||||
line["credit"]=-amt
|
||||
|
||||
amt=0
|
||||
for line in group_lines:
|
||||
amt-=line["debit"]-line["credit"]
|
||||
#XXX
|
||||
if amt >0:
|
||||
line_vals={
|
||||
"description": desc,
|
||||
"account_id": account_id,
|
||||
"debit": amt>0 and amt or 0,
|
||||
"credit": amt<0 and -amt or 0,
|
||||
"due_date": obj.due_date,
|
||||
"partner_id": partner.id,
|
||||
}
|
||||
move_vals["lines"]=[("create",line_vals)]
|
||||
move_vals["lines"]+=[("create",vals) for vals in group_lines]
|
||||
else:
|
||||
move_vals["lines"]=[("create",vals) for vals in group_lines]
|
||||
t03=time.time()
|
||||
dt02=(t03-t02)*1000
|
||||
print("post dt02",dt02)
|
||||
move_id=get_model("account.move").create(move_vals)
|
||||
t04=time.time()
|
||||
dt03=(t04-t03)*1000
|
||||
print("post dt03",dt03)
|
||||
get_model("account.move").post([move_id])
|
||||
t05=time.time()
|
||||
dt04=(t05-t04)*1000
|
||||
print("post dt04",dt04)
|
||||
currency_rate=obj.currency_id.get_rate(date=obj.date,rate_type=rate_type)
|
||||
obj.write({"move_id":move_id,"currency_rate":currency_rate,"state":"waiting_payment"})
|
||||
t06=time.time()
|
||||
dt05=(t06-t05)*1000
|
||||
print("post dt05",dt05)
|
||||
t1=time.time()
|
||||
dt=(t1-t0)*1000
|
||||
print("overrice invoice.post <<< %d ms"%dt)
|
||||
|
||||
|
||||
AccountInvoice.register()
|
||||
|
|
|
@ -201,7 +201,7 @@ class Patient(Model):
|
|||
address_id=get_model('address').create({
|
||||
'type': 'shipping',
|
||||
'partner_id': partner_id,
|
||||
'patient_id': obj.id, #XXX
|
||||
'patient_id': obj.id,
|
||||
'address': 'your address',
|
||||
'address2': 'your address2',
|
||||
'city': 'your city',
|
||||
|
@ -238,28 +238,27 @@ class Patient(Model):
|
|||
ctx['active']=False
|
||||
else:
|
||||
vals['rm_remain_visit']=False
|
||||
|
||||
def update_visit_pending(obj,department_id, branch_id, doctor_id):
|
||||
def update_visit_pending(obj,visit_vals):
|
||||
vids=get_model("clinic.visit").search([['patient_id','=',obj.id],['state','in',['draft','pending']]])
|
||||
for visit in get_model('clinic.visit').browse(vids):
|
||||
visit.write(vals)
|
||||
visit.write(visit_vals)
|
||||
for obj in self.browse(ids):
|
||||
visit_vals={}
|
||||
if 'department_id' in vals.keys():
|
||||
visit_vals={
|
||||
visit_vals.update({
|
||||
'department_id': vals['department_id'],
|
||||
}
|
||||
update_visit_pending(obj,visit_vals)
|
||||
})
|
||||
if 'branch_id' in vals.keys():
|
||||
visit_vals={
|
||||
visit_vals.update({
|
||||
'branch_id': vals['branch_id'],
|
||||
}
|
||||
update_visit_pending(obj,visit_vals)
|
||||
})
|
||||
if 'doctor_id' in vals.keys():
|
||||
visit_vals={
|
||||
visit_vals.update({
|
||||
'doctor_id': vals['doctor_id'],
|
||||
}
|
||||
})
|
||||
if visit_vals:
|
||||
update_visit_pending(obj,visit_vals)
|
||||
# get name
|
||||
# create partner if not found
|
||||
partner_id=obj.partner_id
|
||||
if not partner_id:
|
||||
for partner in get_model("partner").search_browse([['name', '=', obj.name]]):
|
||||
|
@ -281,23 +280,26 @@ class Patient(Model):
|
|||
get_model("address").browse(addr.id).write({
|
||||
'partner_id': partner_id,
|
||||
'patient_id': obj.id,
|
||||
'related_id': "clinic.patient,%s"%obj.id,
|
||||
})
|
||||
else:
|
||||
# in case add more one address
|
||||
if vals.get("addresses"):
|
||||
addr_vals=vals.get("addresses")[0][1]
|
||||
addr_id=get_model("address").create(addr_vals)
|
||||
get_model("address").browse(addr_id).write({
|
||||
'patient_id': obj.id,
|
||||
'partner_id': partner_id,
|
||||
'related_id': "clinic.patient,%s"%obj.id,
|
||||
})
|
||||
del vals['addresses']
|
||||
print("create address for %s"%obj.name, ' ', addr_vals)
|
||||
if obj.rm_remain_visit or vals.get('rm_remain_visit'):
|
||||
visit_ids=get_model('clinic.visit').search([['patient_id','=',obj.id],['state','in',('draft','pending')]])
|
||||
get_model('clinic.visit').delete(visit_ids)
|
||||
print('remove visit auto %s'%visit_ids)
|
||||
super().write(ids,vals,**kw)
|
||||
self.function_store(ids,context=ctx)
|
||||
# update name of partner
|
||||
for obj in self.browse(ids):
|
||||
print(obj.name or "")
|
||||
obj.partner_id.write({
|
||||
|
|
|
@ -93,13 +93,19 @@ class ReportDiscontinuePatient(Model):
|
|||
'resign_date': record.resign_date or '',
|
||||
})
|
||||
no+=1
|
||||
|
||||
month_str=utils.MONTHS['th_TH'][int(month)]
|
||||
start=int(time_start[8:10])
|
||||
stop=int(time_stop[8:10])
|
||||
diff=stop-start
|
||||
sub_name=''
|
||||
if department_id:
|
||||
dpt=get_model("clinic.department").browse(department_id)
|
||||
sub_name="(%s)" % dpt.name or ""
|
||||
elif branch_id:
|
||||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
sub_name="(%s)" % branch.name or ""
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'company_name': '%s %s' % (company.name or "", sub_name),
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'lines': lines,
|
||||
'month': month_str,
|
||||
|
|
|
@ -146,22 +146,27 @@ class ReportHDCaseSummary(Model):
|
|||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['resign_date','>=',time_start])
|
||||
dom.append(['resign_date','<=',time_stop])
|
||||
dom.append(['active','=',False])
|
||||
dom.append(['active','=',False]) #XXX
|
||||
print("1. >>> ", dom)
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
resign_patients=get_model('clinic.patient').search_browse(dom)
|
||||
resign_patients_qty=0
|
||||
resign_patients=[]
|
||||
for pt in get_model('clinic.patient').search_browse(dom):
|
||||
resign_patients_qty+=1
|
||||
resign_patients.append(pt.name)
|
||||
|
||||
del dom[-1]
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic%s'%count]={
|
||||
'month': month_str,
|
||||
'qty': len(resign_patients) or 0,
|
||||
'qty': resign_patients_qty,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=1'%dom,
|
||||
}
|
||||
count+=1
|
||||
|
||||
# all patient who are in hospital on select month
|
||||
dom=[]
|
||||
weekday, crr_total_day=monthrange(year, crr_month)
|
||||
|
@ -173,9 +178,10 @@ class ReportHDCaseSummary(Model):
|
|||
dom.append(['department_id','=',department_id])
|
||||
total_patient=get_model('clinic.patient').search_browse(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
total_patient_qty=len(total_patient) or 0
|
||||
items['topic%s'%count]={
|
||||
'month': next_month_str,
|
||||
'qty': len(total_patient) or 0,
|
||||
'qty': total_patient_qty-resign_patients_qty,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
|
@ -190,17 +196,28 @@ class ReportHDCaseSummary(Model):
|
|||
'unit': 'คน',
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
dom=[]
|
||||
## should be that month or from begin ?
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['reg_date','>=',time_start])
|
||||
#dom.append(['reg_date','>=',time_start])
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['type_id','=',ptype['id']])
|
||||
npatients=get_model("clinic.patient").search(dom)
|
||||
print("2. >>> ", dom)
|
||||
###FIXME remove
|
||||
#dom.append(['resign_date','>=',time_start])
|
||||
#dom.append(['resign_date','<=',time_stop])
|
||||
#dom.append(['active','=',False]) #XXX
|
||||
|
||||
npatients_qty=0
|
||||
for pt in get_model("clinic.patient").search(dom):
|
||||
npatients_qty+=1
|
||||
dom=replace_quote('%s'%dom)
|
||||
items[tkey]={
|
||||
'month': '',
|
||||
'qty': len(npatients),
|
||||
'qty': npatients_qty,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
|
@ -222,8 +239,13 @@ class ReportHDCaseSummary(Model):
|
|||
|
||||
medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)
|
||||
year=year+543
|
||||
print('branch_id ', branch_id)
|
||||
print('department_id ', department_id)
|
||||
sub_name=''
|
||||
if department_id:
|
||||
dpt=get_model("clinic.department").browse(department_id)
|
||||
sub_name="(%s)" % dpt.name or ""
|
||||
elif branch_id:
|
||||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
sub_name="(%s)" % branch.name or ""
|
||||
data={
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
|
@ -235,7 +257,7 @@ class ReportHDCaseSummary(Model):
|
|||
'resign_patients': get_model("clinic.report.discontinue.patient").get_report_data(ids=[],context=context)['lines'],
|
||||
'medicals': medicals['lines'],
|
||||
'titles': medicals['titles'],
|
||||
'company_name': company.name or "",
|
||||
'company_name': '%s %s'% (company.name or "", sub_name),
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
}
|
||||
return data
|
||||
|
|
|
@ -159,18 +159,21 @@ class ReportMedicalSummary(Model):
|
|||
|
||||
# remove zero
|
||||
for line in lines:
|
||||
#st=""
|
||||
for sline in line['sub_lines']:
|
||||
qty=sline['qty']
|
||||
if not qty:
|
||||
sline['qty']=''
|
||||
#st+="%s"%(qty)
|
||||
#print(st)
|
||||
lines=sorted(lines, key=lambda x: x['prod_name'])
|
||||
year=int(year)+543
|
||||
|
||||
sub_name=''
|
||||
if department_id:
|
||||
dpt=get_model("clinic.department").browse(department_id)
|
||||
sub_name="(%s)" % dpt.name or ""
|
||||
elif branch_id:
|
||||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
sub_name="(%s)" % branch.name or ""
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'company_name': '%s %s' % (company.name or "", sub_name),
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'titles': titles,
|
||||
'lines': lines,
|
||||
|
|
|
@ -96,8 +96,15 @@ class ReportRecentPatient(Model):
|
|||
start=int(time_start[8:10])
|
||||
stop=int(time_stop[8:10])
|
||||
diff=stop-start
|
||||
sub_name=''
|
||||
if department_id:
|
||||
dpt=get_model("clinic.department").browse(department_id)
|
||||
sub_name="(%s)" % dpt.name or ""
|
||||
elif branch_id:
|
||||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
sub_name="(%s)" % branch.name or ""
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'company_name': '%s %s'%(company.name or "", sub_name),
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'lines': lines,
|
||||
'month': month_str,
|
||||
|
|
|
@ -110,21 +110,15 @@ class ClinicSetting(Model):
|
|||
if user_id !=1:
|
||||
print("Only admin!!")
|
||||
return
|
||||
for st in get_model("clinic.staff").search_browse([]):
|
||||
level=st.level_id
|
||||
for citem in get_model("clinic.cycle.item").search_browse([]):
|
||||
for line in citem.lines:
|
||||
nurse=line.nurse_id
|
||||
level=nurse.level_id
|
||||
if not line.level_id:
|
||||
if level:
|
||||
if level.name=='TH':
|
||||
st.write({
|
||||
'categ_id': 3,
|
||||
line.write({
|
||||
'level_id': level.id
|
||||
})
|
||||
#for citem in get_model("clinic.cycle.item").search_browse([]):
|
||||
#for line in citem.lines:
|
||||
#nurse=line.nurse_id
|
||||
#level=nurse.level_id
|
||||
#if level:
|
||||
#line.write({
|
||||
#'level_id': level.id
|
||||
#})
|
||||
print("Done!")
|
||||
|
||||
def update_departments(self,ids,context={}):
|
||||
|
|
|
@ -106,7 +106,7 @@ class Staff(Model):
|
|||
"name_check": fields.Char("Name",function="_get_name",function_multi=True,store=True),
|
||||
"name_eng": fields.Char("Eng Name",search=True),
|
||||
"nick_name": fields.Char("Nick Name",search=True),
|
||||
"identification" : fields.Char("Identification Card"),
|
||||
"identification" : fields.Char("ID Card"),
|
||||
"expiry_card" : fields.Date("Expired Card"),
|
||||
"birthday": fields.Date("Birthday",search=True),
|
||||
"age": fields.Integer("Age", function="_get_age"),
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import time
|
||||
|
||||
from netforce.model import Model, fields
|
||||
from netforce.access import get_active_company
|
||||
|
||||
|
@ -7,20 +9,37 @@ class StaffRotation(Model):
|
|||
_multi_company=True
|
||||
|
||||
_fields={
|
||||
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type",search=True),
|
||||
"staff_id": fields.Many2One("clinic.staff","Staff", search=True),
|
||||
"level_id": fields.Many2One("clinic.staff.level","Staff Level", search=True),
|
||||
"from_company_id": fields.Many2One("company", "From", search=True),
|
||||
"to_company_id": fields.Many2One("company", "To", search=True),
|
||||
'categ_id': fields.Many2One("clinic.staff.categ","Category",search=True),
|
||||
"level_id": fields.Many2One("clinic.staff.level","Level", search=True),
|
||||
"hire_date": fields.Date("Hire Date", search=True),
|
||||
"resign_date": fields.Date("Resign Date", search=True),
|
||||
"wage": fields.Float("Wage"),
|
||||
"max_cycle": fields.Integer("Max Cycle"),
|
||||
"ot_per_cycle": fields.Float("OT Per Cycle"),
|
||||
"ot_per_cycle": fields.Float("OT/Cycle"),
|
||||
"note": fields.Text("Note"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
}
|
||||
_defaults={
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
'hire_date': time.strftime("%Y-%m-%d"),
|
||||
'state': 'draft',
|
||||
'type': 'nurse',
|
||||
}
|
||||
|
||||
def to_draft(self,ids,context={}):
|
||||
for obj in self.browse(ids):
|
||||
obj.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
|
||||
def approve(self,ids,context={}):
|
||||
for obj in self.browse(ids):
|
||||
obj.write({
|
||||
'state': 'approved',
|
||||
})
|
||||
|
||||
StaffRotation.register()
|
||||
|
|
Loading…
Reference in New Issue