prevent duplicat staff

production
watcha.h 2015-10-25 15:14:50 +07:00
parent 210ddcc5a8
commit e3a75860ea
3 changed files with 13 additions and 4 deletions

View File

@ -28,6 +28,9 @@ class Migration(migration.Migration):
for hdcase in get_model("clinic.hd.case").search_browse(dom):
if not hdcase.pickings:
print('gen picking for %s in %s'%(hdcase.number, hdcase.date))
hdcase.make_pickings()
ctx={
'migrate':True,
}
hdcase.make_pickings(context=ctx)
Migration.register()

View File

@ -819,9 +819,12 @@ class HDCase(Model):
if patient.type_id.main_product:
if len(prod_code)>1:
prods=get_model('product').search_browse(['code','=',prod_code])
if not prods:
raise Exception("Can not create good issue: product code %s is not found!"%prod_code)
prod=prods[0]
if not context.get('migrate'):
if not prods:
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:
continue
prod_exist_ids.append(prod.id)

View File

@ -203,6 +203,9 @@ class Visit(Model):
hd_case_id=None
if obj.hd_cases:
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_id=hd_case.id
else: