From 481d554913ceb37323ef8d353ee6ae23d681122d Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 24 Mar 2015 09:51:02 +0700 Subject: [PATCH] setting --- netforce_clinic/layouts/clinic_setting.xml | 17 +++++-- netforce_clinic/models/setting.py | 58 +++++++++++++++++++++- netforce_clinic/todo.txt | 16 ------ 3 files changed, 69 insertions(+), 22 deletions(-) diff --git a/netforce_clinic/layouts/clinic_setting.xml b/netforce_clinic/layouts/clinic_setting.xml index 89e96d3..9660d2a 100644 --- a/netforce_clinic/layouts/clinic_setting.xml +++ b/netforce_clinic/layouts/clinic_setting.xml @@ -1,11 +1,20 @@
+ + + - - + + + + + + - - + + diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 193beda..82e93d8 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -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() diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 3145ee8..e69de29 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -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