From 9f1fe78829f3244a627ea9f969a6d08129546b01 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Fri, 18 Dec 2015 13:55:19 +0700 Subject: [PATCH] improve --- .../layouts/clinic_dialyzer_form.xml | 2 +- netforce_clinic/migrations/__init__.py | 3 +- .../migrations/rename_dbl_hdcase_number.py | 28 +++++++++++++++++++ netforce_clinic/models/base_user.py | 1 + netforce_clinic/models/department.py | 2 +- netforce_clinic/models/hd_case.py | 3 +- 6 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 netforce_clinic/migrations/rename_dbl_hdcase_number.py diff --git a/netforce_clinic/layouts/clinic_dialyzer_form.xml b/netforce_clinic/layouts/clinic_dialyzer_form.xml index 63b996f..1c526c9 100644 --- a/netforce_clinic/layouts/clinic_dialyzer_form.xml +++ b/netforce_clinic/layouts/clinic_dialyzer_form.xml @@ -2,7 +2,7 @@ diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py index 8bbdb6c..12c536e 100644 --- a/netforce_clinic/migrations/__init__.py +++ b/netforce_clinic/migrations/__init__.py @@ -4,4 +4,5 @@ #from . import tb_ap_import #from . import check_seq #from . import del_gi -from . import restore_picking +#from . import restore_picking +from . import rename_dbl_hdcase_number diff --git a/netforce_clinic/migrations/rename_dbl_hdcase_number.py b/netforce_clinic/migrations/rename_dbl_hdcase_number.py new file mode 100644 index 0000000..5c3b392 --- /dev/null +++ b/netforce_clinic/migrations/rename_dbl_hdcase_number.py @@ -0,0 +1,28 @@ +import time + +from netforce.model import get_model +from netforce import migration +from netforce.access import set_active_user, set_active_company +from netforce.database import get_connection + +class Migration(migration.Migration): + _name="clinic.rename.dbl.hdcase.number" + _version="2.12.2" + + def migrate(self): + db=get_connection() + res=db.query(""" + select c, number from (select count(number) as c,number from clinic_hd_case group by number order by number) as r1 where c > 1; + """) + for r in res: + number=r['number'] + if number!='/': + count=1 + for hdcase in get_model('clinic.hd.case').search_browse([['number','=',number]]): + hdcase.write({ + 'number': number+"."+str(count), + }) + count+=1 + print(r) + +Migration.register() diff --git a/netforce_clinic/models/base_user.py b/netforce_clinic/models/base_user.py index f5e51eb..95b9cab 100644 --- a/netforce_clinic/models/base_user.py +++ b/netforce_clinic/models/base_user.py @@ -14,4 +14,5 @@ class User(Model): _defaults={ 'auto_load_dpt': True, } + User.register() diff --git a/netforce_clinic/models/department.py b/netforce_clinic/models/department.py index c223c93..ffc549c 100644 --- a/netforce_clinic/models/department.py +++ b/netforce_clinic/models/department.py @@ -91,7 +91,7 @@ class Department(Model): ['clinic.sickbed','department_id.code','='], ['clinic.shop','department_id.code','='], ['clinic.department','code','='], #XXX - ['clinic.dialyzer','department_id.code','='], + #['clinic.dialyzer','department_id.code','='], # support to use different location ['clinic.schedule','department_id.code','='], ] for obj in self.browse(ids): diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 41dbcba..bd51cb6 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -319,7 +319,8 @@ class HDCase(Model): "date": lambda *a: time.strftime("%Y-%m-%d"), "time_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), "time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), - 'number': '/', + #'number': '/', + 'number': _get_number, "company_id": lambda *a: get_active_company(), 'hd_acc': 'o', 'hd_mode': 'chronic',