def create_serial_series(series, start_seed, description): if isinstance(series, unicode): series = series.encode('ascii', 'replace') if isinstance(start_seed, unicode): start_seed = start_seed.encode('ascii', 'replace') if isinstance(description, unicode): description = description.encode('ascii', 'replace') return controller.create_series_obj( series=series, start_seed=start_seed, description=description)
def get_serialno(series=None, efield=None, register=True, start_seed='100A', create_series=False, session=None): series = series.upper() try: series_obj = controller.get_series_obj(series=series, session=session) except controller.SeriesNotFound: if not create_series: raise series_obj = None if series_obj is not None: last_seed = series_obj.last_seed logger.debug("Found last seed for series " + str(series) + " : " + str(last_seed)) generator = idstring.IDstring(seed=last_seed) new_sno = generator + 1 if register is True: logger.debug("Updating seed for series " + series + " : " + str(new_sno.get_seed())) series_obj.last_seed = new_sno.get_seed() register_serialno(sno=series + '-' + new_sno, efield=efield, session=session) else: logger.info("Not updating seed for series " + series + " : " + str(new_sno.get_seed())) return series + '-' + new_sno else: logger.info("Could not find series in db : " + series) generator = idstring.IDstring(seed=start_seed) if register is True: logger.info("Creating series in db : " + series) controller.create_series_obj(series=series, start_seed=start_seed, session=session) register_serialno(sno=series + '-' + generator, efield=efield, session=session) else: logger.info("NOT Creating series in db : " + series) return series + '-' + generator
def create_serial_series(series, start_seed, description): if isinstance(series, unicode): series = series.encode('ascii', 'replace') if isinstance(start_seed, unicode): start_seed = start_seed.encode('ascii', 'replace') if isinstance(description, unicode): description = description.encode('ascii', 'replace') return controller.create_series_obj(series=series, start_seed=start_seed, description=description)
def get_serialno(series=None, efield=None, register=True, start_seed='100A', create_series=False, session=None): series = series.upper() try: series_obj = controller.get_series_obj(series=series, session=session) except controller.SeriesNotFound: if not create_series: raise series_obj = None if series_obj is not None: last_seed = series_obj.last_seed logger.debug("Found last seed for series " + str(series) + " : " + str(last_seed)) generator = idstring.IDstring(seed=last_seed) new_sno = generator + 1 if register is True: logger.debug("Updating seed for series " + series + " : " + str(new_sno.get_seed())) series_obj.last_seed = new_sno.get_seed() register_serialno( sno=series + '-' + new_sno, efield=efield, session=session ) else: logger.info("Not updating seed for series " + series + " : " + str(new_sno.get_seed())) return series + '-' + new_sno else: logger.info("Could not find series in db : " + series) generator = idstring.IDstring(seed=start_seed) if register is True: logger.info("Creating series in db : " + series) controller.create_series_obj( series=series, start_seed=start_seed, session=session ) register_serialno( sno=series + '-' + generator, efield=efield, session=session ) else: logger.info("NOT Creating series in db : " + series) return series + '-' + generator