v2
watcha.h 2017-06-05 00:47:34 +07:00
parent 2d1b3e0bba
commit d5f07de974
3 changed files with 32 additions and 34 deletions

View File

@ -9,20 +9,10 @@ from . import utils
class PatientMove(Model):
_name="clinic.patient.move"
def get_all(self, ids, context={}):
res={}
for obj in self.browse(ids):
res[obj.id]={
'date_move': obj.date.split(" ")[0],
}
return res
_fields={
'patient_id': fields.Many2One('clinic.patient','Patient',search=True),
'date': fields.DateTime("Date", required=True,search=True),
'date_move': fields.Date("Date Move", function="get_all", function_multi=True, store=True),
'date': fields.Date("Date", required=True,search=True),
'location_from_id': fields.Many2One("clinic.department","Location From",search=True),
'location_to_id': fields.Many2One("clinic.department","Location To",search=True),
"state": fields.Selection([['normal','Normal'],['new','New'],['dispose','Dispose']], "State"),
@ -37,14 +27,15 @@ class PatientMove(Model):
def get_data(self, date, department_id, context={}):
if not date:
raise Exception("Missing date!")
y,m,d=date.split("-")
y=int(y)
m=int(m)
weekday, day_month=monthrange(y, m)
cond1=[
['date','>=','%s-%s-01 00:00:00'%(y,str(m).zfill(2))],
['date','<=','%s-%s-%s 23:59:59'%(y,str(m).zfill(2),day_month)],
['date','>=','%s-%s-01'%(y,str(m).zfill(2))],
['date','<=','%s-%s-%s'%(y,str(m).zfill(2),day_month)],
['location_to_id','=', department_id],
]
cond=cond1+[['state','=','normal']]
@ -99,21 +90,34 @@ class PatientMove(Model):
}
return res
def auto_get_data(self, context={}):
def auto_get_data(self, date, department_id, context={}):
user_id=get_active_user()
set_active_user(1)
datenow=time.strftime("%Y-%m-%d")
date=context.get("date")
if not date:
raise Exception("Missing date!")
if not department_id:
raise Exception("Missing department!")
y,m,d=date.split("-")
weekday, day_month=monthrange(int(y), int(m))
cond=[
['date','>=','%s-%s-01 00:00:00'%(y,m)],
['date','<=','%s-%s-%s 23:59:59'%(y,m,day_month)],
['date','>=','%s-%s-01'%(y,m)],
['date','<=','%s-%s-%s'%(y,m,day_month)],
['location_to_id','=',department_id],
]
res=self.search(cond)
#XXX reset data
if res and date > datenow:
ids=self.search(cond)
print("reset data...")
print(ids)
self.delete(ids)
res=None
# copy data from previous month
if not res:
y=int(y)
@ -124,8 +128,9 @@ class PatientMove(Model):
weekday, day_month=monthrange(int(y), int(m))
cond=[
['date','>=','%s-%s-01 00:00:00'%(y,m)],
['date','<=','%s-%s-%s 23:59:59'%(y,m,day_month)],
['date','>=','%s-%s-01'%(y,m)],
['date','<=','%s-%s-%s'%(y,m,day_month)],
['location_to_id','=',department_id],
]
res=self.search_browse(cond)
for obj in res:
@ -166,14 +171,4 @@ class PatientMove(Model):
set_active_user(user_id)
def create(self, vals, **kw):
new_id=super().create(vals,**kw)
self.function_store([new_id])
return new_id
def write(self, ids, vals, **kw):
super().write(ids, vals, **kw)
self.function_store(ids)
PatientMove.register()

View File

@ -30,12 +30,8 @@ class ReportHDCaseSummaryV2(Model):
def get_report_data(self, ids, context={}):
defaults=self.default_get(context=context)
month=defaults.get("month")
y,m,d=month.split("-")
branch_id=defaults.get("branch_id")
department_id=defaults.get("department_id")
@ -47,7 +43,7 @@ class ReportHDCaseSummaryV2(Model):
y,m,d=month.split("-")
#auto gen at the fist time of that month
get_model("clinic.patient.move").auto_get_data(context={'date': month})
get_model("clinic.patient.move").auto_get_data(date=month, department_id=department_id)
crr_month=m
weekday, total_day=monthrange(int(y), int(m))

View File

@ -1,3 +1,10 @@
move
new
dispose
==============
redesign print payment & invoice from hdcase
- print payment
- direct payment