migrate/update sequence
parent
a5afa558e0
commit
b9436c5990
|
@ -1,4 +1,5 @@
|
||||||
#from . import clinic_setting
|
#from . import clinic_setting
|
||||||
#from . import repost_invoice
|
#from . import repost_invoice
|
||||||
from . import conv_bal
|
#from . import conv_bal
|
||||||
#from . import tb_ap_import
|
#from . import tb_ap_import
|
||||||
|
from . import check_seq
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.access import set_active_user, set_active_company
|
||||||
|
|
||||||
|
class Migration(migration.Migration):
|
||||||
|
_name="clinic.check.seq"
|
||||||
|
_version="2.11.0"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
set_active_user(1)
|
||||||
|
set_active_company(1)
|
||||||
|
fnames=['branch_id','prefix']
|
||||||
|
seqs=dict([(x['branch_id'][0],x['prefix']) for x in get_model("sequence").search_read([['type','=','clinic_hdcase']],fnames)])
|
||||||
|
print('seqs ',seqs)
|
||||||
|
count=0
|
||||||
|
for hdcase in get_model('clinic.hd.case').search_browse([]):
|
||||||
|
seq=seqs[hdcase.branch_id.id]
|
||||||
|
rp=seq.split("/")[-1].replace("-","")
|
||||||
|
if '/' in hdcase.number and hdcase.number!='/':
|
||||||
|
if seq not in hdcase.number:
|
||||||
|
pf=hdcase.number.split('-')[0].split("/")[-1]
|
||||||
|
new_hdcase_number=hdcase.number.replace(pf,rp)
|
||||||
|
new_visit_number=hdcase.visit_id.number.replace(pf,rp)
|
||||||
|
print(hdcase.number, new_hdcase_number,hdcase.department_id.name)
|
||||||
|
print(hdcase.visit_id.number, new_visit_number, hdcase.visit_id.department_id.name)
|
||||||
|
hdcase.write({
|
||||||
|
'number': new_hdcase_number,
|
||||||
|
})
|
||||||
|
hdcase.visit_id.write({
|
||||||
|
'number': new_visit_number,
|
||||||
|
})
|
||||||
|
print('-'*100)
|
||||||
|
#print(seq, ' : ', hdcase.number, hdcase.visit_id.number, hdcase.date, hdcase.patient_id.name)
|
||||||
|
count+=1
|
||||||
|
print('total unmatch', count)
|
||||||
|
|
||||||
|
Migration.register()
|
Loading…
Reference in New Issue