def _get_next_batch_number(self): max_db = StorableBatch.get_max_batch_number(self.store) max_used = max_value_for(self._get_used_batches() | set([max_db])) if not api.sysparam.get_bool('SYNCHRONIZED_MODE'): return next_value_for(max_used) # On synchronized mode we need to append the branch acronym # to avoid conflicts max_used_list = max_used.split('-') if len(max_used_list) == 1: # '123' max_used = max_used_list[0] elif len(max_used_list) == 2: # '123-AB' max_used = max_used_list[0] else: # TODO: Maybe we should allow only one dash in the batch number # '123-456-AB' max_used = ''.join(max_used_list[:-1]) branch = api.get_current_branch(self.store) if not branch.acronym: raise ValueError("branch '%s' needs an acronym since we are on " "synchronized mode" % (branch.get_description(),)) return '-'.join([next_value_for(max_used), branch.acronym])