refactor
parent
2d1b3e0bba
commit
d5f07de974
|
@ -9,20 +9,10 @@ from . import utils
|
||||||
|
|
||||||
class PatientMove(Model):
|
class PatientMove(Model):
|
||||||
_name="clinic.patient.move"
|
_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={
|
_fields={
|
||||||
'patient_id': fields.Many2One('clinic.patient','Patient',search=True),
|
'patient_id': fields.Many2One('clinic.patient','Patient',search=True),
|
||||||
'date': fields.DateTime("Date", required=True,search=True),
|
'date': fields.Date("Date", required=True,search=True),
|
||||||
'date_move': fields.Date("Date Move", function="get_all", function_multi=True, store=True),
|
|
||||||
'location_from_id': fields.Many2One("clinic.department","Location From",search=True),
|
'location_from_id': fields.Many2One("clinic.department","Location From",search=True),
|
||||||
'location_to_id': fields.Many2One("clinic.department","Location To",search=True),
|
'location_to_id': fields.Many2One("clinic.department","Location To",search=True),
|
||||||
"state": fields.Selection([['normal','Normal'],['new','New'],['dispose','Dispose']], "State"),
|
"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={}):
|
def get_data(self, date, department_id, context={}):
|
||||||
if not date:
|
if not date:
|
||||||
raise Exception("Missing date!")
|
raise Exception("Missing date!")
|
||||||
|
|
||||||
y,m,d=date.split("-")
|
y,m,d=date.split("-")
|
||||||
y=int(y)
|
y=int(y)
|
||||||
m=int(m)
|
m=int(m)
|
||||||
weekday, day_month=monthrange(y, m)
|
weekday, day_month=monthrange(y, m)
|
||||||
|
|
||||||
cond1=[
|
cond1=[
|
||||||
['date','>=','%s-%s-01 00:00:00'%(y,str(m).zfill(2))],
|
['date','>=','%s-%s-01'%(y,str(m).zfill(2))],
|
||||||
['date','<=','%s-%s-%s 23:59:59'%(y,str(m).zfill(2),day_month)],
|
['date','<=','%s-%s-%s'%(y,str(m).zfill(2),day_month)],
|
||||||
['location_to_id','=', department_id],
|
['location_to_id','=', department_id],
|
||||||
]
|
]
|
||||||
cond=cond1+[['state','=','normal']]
|
cond=cond1+[['state','=','normal']]
|
||||||
|
@ -99,21 +90,34 @@ class PatientMove(Model):
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def auto_get_data(self, context={}):
|
def auto_get_data(self, date, department_id, context={}):
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
set_active_user(1)
|
set_active_user(1)
|
||||||
|
datenow=time.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
date=context.get("date")
|
|
||||||
if not date:
|
if not date:
|
||||||
raise Exception("Missing date!")
|
raise Exception("Missing date!")
|
||||||
|
if not department_id:
|
||||||
|
raise Exception("Missing department!")
|
||||||
|
|
||||||
y,m,d=date.split("-")
|
y,m,d=date.split("-")
|
||||||
weekday, day_month=monthrange(int(y), int(m))
|
weekday, day_month=monthrange(int(y), int(m))
|
||||||
cond=[
|
cond=[
|
||||||
['date','>=','%s-%s-01 00:00:00'%(y,m)],
|
['date','>=','%s-%s-01'%(y,m)],
|
||||||
['date','<=','%s-%s-%s 23:59:59'%(y,m,day_month)],
|
['date','<=','%s-%s-%s'%(y,m,day_month)],
|
||||||
|
['location_to_id','=',department_id],
|
||||||
]
|
]
|
||||||
res=self.search(cond)
|
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
|
# copy data from previous month
|
||||||
if not res:
|
if not res:
|
||||||
y=int(y)
|
y=int(y)
|
||||||
|
@ -124,8 +128,9 @@ class PatientMove(Model):
|
||||||
|
|
||||||
weekday, day_month=monthrange(int(y), int(m))
|
weekday, day_month=monthrange(int(y), int(m))
|
||||||
cond=[
|
cond=[
|
||||||
['date','>=','%s-%s-01 00:00:00'%(y,m)],
|
['date','>=','%s-%s-01'%(y,m)],
|
||||||
['date','<=','%s-%s-%s 23:59:59'%(y,m,day_month)],
|
['date','<=','%s-%s-%s'%(y,m,day_month)],
|
||||||
|
['location_to_id','=',department_id],
|
||||||
]
|
]
|
||||||
res=self.search_browse(cond)
|
res=self.search_browse(cond)
|
||||||
for obj in res:
|
for obj in res:
|
||||||
|
@ -166,14 +171,4 @@ class PatientMove(Model):
|
||||||
|
|
||||||
set_active_user(user_id)
|
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()
|
PatientMove.register()
|
||||||
|
|
|
@ -30,12 +30,8 @@ class ReportHDCaseSummaryV2(Model):
|
||||||
|
|
||||||
def get_report_data(self, ids, context={}):
|
def get_report_data(self, ids, context={}):
|
||||||
defaults=self.default_get(context=context)
|
defaults=self.default_get(context=context)
|
||||||
|
|
||||||
month=defaults.get("month")
|
month=defaults.get("month")
|
||||||
|
|
||||||
|
|
||||||
y,m,d=month.split("-")
|
y,m,d=month.split("-")
|
||||||
|
|
||||||
branch_id=defaults.get("branch_id")
|
branch_id=defaults.get("branch_id")
|
||||||
department_id=defaults.get("department_id")
|
department_id=defaults.get("department_id")
|
||||||
|
|
||||||
|
@ -47,7 +43,7 @@ class ReportHDCaseSummaryV2(Model):
|
||||||
y,m,d=month.split("-")
|
y,m,d=month.split("-")
|
||||||
|
|
||||||
#auto gen at the fist time of that month
|
#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
|
crr_month=m
|
||||||
weekday, total_day=monthrange(int(y), int(m))
|
weekday, total_day=monthrange(int(y), int(m))
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
move
|
||||||
|
new
|
||||||
|
dispose
|
||||||
|
|
||||||
|
==============
|
||||||
|
|
||||||
|
|
||||||
redesign print payment & invoice from hdcase
|
redesign print payment & invoice from hdcase
|
||||||
- print payment
|
- print payment
|
||||||
- direct payment
|
- direct payment
|
||||||
|
|
Loading…
Reference in New Issue