Ignore:
Timestamp:
30 Apr 2010, 06:39:44 (15 years ago)
Author:
Henrik Bettermann
Message:

continue numbering of pin batches instead of filling gaps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_create_do.py

    r502 r5179  
    88from Products.CMFCore.utils import getToolByName
    99
     10#try:
     11#    from Products.zdb import set_trace
     12#except:
     13#    def set_trace():
     14#        pass
     15
     16
    1017prefix = datamodel.get('prefix').upper()
    1118datamodel.set('prefix',prefix)
    1219bl = context.portal_catalog({'meta_type': "ScratchCardBatch",})
    1320b_ids = []
     21
    1422for b in bl:
    1523    b_ids.append(b.getId)
    16 next = 1
    17 while b_ids and "%s_%d" % (prefix,next) in b_ids:
    18     next += 1
     24
     25p_ids = [p_id for p_id in b_ids if p_id.startswith(prefix)]
     26if p_ids:
     27    max_bno = max([int(bno.split('_')[1]) for bno in p_ids])
     28    next = max_bno+1
     29else:
     30    next = 1
     31
     32#next = 1
     33#while b_ids and "%s_%d" % (prefix,next) in b_ids:
     34#    next += 1
     35
    1936id = "%s_%d" % (prefix,next)
     37
    2038datamodel.set('batch_no',next)
    21 ##language = datamodel.get('Language')
    22 ##if not language:
    23 ##    ts = getToolByName(context, 'translation_service')
    24 ##    language = ts.getSelectedLanguage()
    25 
    26 # Datamodel is passed so that flexti can initialize the object.
    2739new_id = context.invokeFactory(type_name, id, datamodel=datamodel,
    2840                               )
     
    3345ob.getContent().edit(mapping=datamodel)
    3446
    35 #context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0
    36 
    3747return ob
Note: See TracChangeset for help on using the changeset viewer.