#NEWLINE# @ frappe . whitelist ( ) #NEWLINE# def get_next( doctype , value , prev , filters = None , order_by = 'modified desc' ) : #NEWLINE# #INDENT# import frappe.desk.reportview #NEWLINE# prev = ( not int ( prev ) ) #NEWLINE# ( sort_field , sort_order ) = order_by . split ( ' ' ) #NEWLINE# if ( not filters ) : #NEWLINE# #INDENT# filters = [ ] #NEWLINE# #UNINDENT# if isinstance ( filters , basestring ) : #NEWLINE# #INDENT# filters = json . loads ( filters ) #NEWLINE# #UNINDENT# condition = ( '>' if ( sort_order . lower ( ) == 'desc' ) else '<' ) #NEWLINE# if prev : #NEWLINE# #INDENT# condition = ( '<' if ( condition == '>' ) else '<' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sort_order = ( 'asc' if ( sort_order . lower ( ) == 'desc' ) else 'desc' ) #NEWLINE# #UNINDENT# if ( not ( order_by [ 0 ] in [ f [ 1 ] for f in filters ] ) ) : #NEWLINE# #INDENT# filters . append ( [ doctype , sort_field , condition , value ] ) #NEWLINE# #UNINDENT# res = frappe . desk . reportview . execute ( doctype , fields = [ 'name' ] , filters = filters , order_by = ( ( sort_field + ' ' ) + sort_field ) , limit_start = 0 , limit_page_length = 1 , as_list = True ) #NEWLINE# if ( not res ) : #NEWLINE# #INDENT# frappe . msgprint ( _ ( 'No further records' ) ) #NEWLINE# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return res [ 0 ] [ 0 ]