conv_bal
watcha.h 2015-03-24 09:51:02 +07:00
parent 2f011dcaa8
commit 481d554913
3 changed files with 69 additions and 22 deletions

View File

@ -1,11 +1,20 @@
<form model="clinic.setting" title="Clinic Settings">
<head>
<button string="Options" dropdown="1">
<item string="Manual Generate Visit" method="manual_generate_visit" confirm="This action will remove all pending visit of this month and generate new one. Are you sure?"/>
</button>
</head>
<separator string="Visit"/>
<field name="find_dlz" span="4"/>
<field name="auto_gen_visit" span="6"/>
<group form_layout="stacked">
<field name="find_dlz"/>
<newline/>
<field name="auto_gen_visit" string="Next Gen"/>
<field name="next_date" span="3"/>
</group>
<separator string="HD Case"/>
<group form_layout="stacked">
<field name="waiting_approval" span="3"/>
<field name="real_time" span="3"/>
<!--<field name="waiting_approval" span="3"/>-->
<!--<field name="real_time" span="3"/>-->
<field name="auto_gen" invisible="1" span="3"/>
<field name="products" nolabel="1">
<list>

View File

@ -1,4 +1,5 @@
from datetime import datetime
from datetime import datetime, timedelta
from calendar import monthrange
from netforce.model import Model, fields, get_model
@ -51,6 +52,7 @@ class ClinicSetting(Model):
"import_account_id": fields.Many2One("account.account","Import Account",multi_company=True),
'helper_categ_id': fields.Many2One("clinic.staff.categ","Helper Category"),
'base_salary_day': fields.Float("Base Salary Day"),
'next_date': fields.DateTime("Next Gen"),
}
_defaults={
@ -954,6 +956,58 @@ class ClinicSetting(Model):
def generate_visit(self,ids,context={}):
obj=self.browse(ids)[0]
print(">>>>")
if obj.auto_gen_visit:
datenow=datetime.now().strftime("%Y-%m-%d")
year,month,day=datenow.split("-")
weekday, total_day=monthrange(int(year), int(month))
date_from="%s-%s-%s"%(year,month,"01")
date_to="%s-%s-%s"%(year,month,("%s"%total_day).zfill(2))
mobj=get_model('clinic.make.apt')
vals={
'date_from': date_from,
'date_to': date_to,
}
print('duration generate ', vals)
mid=mobj.create(vals)
m=mobj.browse(mid)
m.load(context=context)
m.gen(context=context)
def auto_generate_visit(self,ids,context={}):
obj=self.browse(ids)[0]
print("auto generate visit running...")
datenow=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print('now : ', datenow, 'next gen :',obj.next_date)
print('ans: ', datenow>=obj.next_date)
if datenow>=obj.next_date:
obj.generate_visit()
# update next job
date=datetime.now()
y,m,d=date.strftime("%Y-%m-%d").split("-")
m=int(m)
if m>=12:
m=1
y=int(y)+1
else:
m+=1
m=str(m).zfill(2)
next_date='%s-%s-%s 00:00:00'%(y,m,'01')
obj.write({
'next_date': next_date,
})
print("Done!")
print("Next Gen is ", obj.next_date)
def manual_generate_visit(self,ids,context={}):
dom=[]
dom.append(['name','=','Generate Visit'])
sec=10 # waiting in 10 sec
date=datetime.now()+timedelta(0,sec) # days, seconds
next_date=date.strftime("%Y-%m-%d %H:%M:%S")
obj=self.browse(ids)[0]
obj.write(
{ 'next_date': next_date,
})
print('next runing in 10 seconds ', date)
ClinicSetting.register()

View File

@ -1,16 +0,0 @@
=====
- if department of staff or patient not related to department profile of user , it will show error's permission denied.
=====
- report
- walkin
- receipt **
-
- update & merge data
- patient
- doctor
- *** template:
- change company name in all report template
====
improvement:
1. ย้ายผู้ป่วย
2. ปรับ level