prevent duplicat staff
parent
210ddcc5a8
commit
e3a75860ea
|
@ -28,6 +28,9 @@ class Migration(migration.Migration):
|
||||||
for hdcase in get_model("clinic.hd.case").search_browse(dom):
|
for hdcase in get_model("clinic.hd.case").search_browse(dom):
|
||||||
if not hdcase.pickings:
|
if not hdcase.pickings:
|
||||||
print('gen picking for %s in %s'%(hdcase.number, hdcase.date))
|
print('gen picking for %s in %s'%(hdcase.number, hdcase.date))
|
||||||
hdcase.make_pickings()
|
ctx={
|
||||||
|
'migrate':True,
|
||||||
|
}
|
||||||
|
hdcase.make_pickings(context=ctx)
|
||||||
|
|
||||||
Migration.register()
|
Migration.register()
|
||||||
|
|
|
@ -819,9 +819,12 @@ class HDCase(Model):
|
||||||
if patient.type_id.main_product:
|
if patient.type_id.main_product:
|
||||||
if len(prod_code)>1:
|
if len(prod_code)>1:
|
||||||
prods=get_model('product').search_browse(['code','=',prod_code])
|
prods=get_model('product').search_browse(['code','=',prod_code])
|
||||||
if not prods:
|
if not context.get('migrate'):
|
||||||
raise Exception("Can not create good issue: product code %s is not found!"%prod_code)
|
if not prods:
|
||||||
prod=prods[0]
|
raise Exception("Can not create goods issue: product code %s is not found!"%prod_code)
|
||||||
|
prod=prods[0]
|
||||||
|
else:
|
||||||
|
continue
|
||||||
if prod_ids and prod.id not in prod_ids or prod.id in prod_exist_ids:
|
if prod_ids and prod.id not in prod_ids or prod.id in prod_exist_ids:
|
||||||
continue
|
continue
|
||||||
prod_exist_ids.append(prod.id)
|
prod_exist_ids.append(prod.id)
|
||||||
|
|
|
@ -203,6 +203,9 @@ class Visit(Model):
|
||||||
hd_case_id=None
|
hd_case_id=None
|
||||||
if obj.hd_cases:
|
if obj.hd_cases:
|
||||||
hd_case=obj.hd_cases[0]
|
hd_case=obj.hd_cases[0]
|
||||||
|
# prevent duplicate staff: del old staff
|
||||||
|
for staff in hd_case.staffs:
|
||||||
|
staff.delete()
|
||||||
hd_case.write(vals)
|
hd_case.write(vals)
|
||||||
hd_case_id=hd_case.id
|
hd_case_id=hd_case.id
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue