@@ -180,6 +180,7 @@ def get_many(self,
180180 :param order: Ordering clause
181181 :return: List of dictionaries with the requested fields
182182 """
183+ # Set options
183184 if options is None :
184185 options = {}
185186 # Limit results only to selected fields
@@ -224,8 +225,8 @@ def all(self,
224225
225226 def find (self ,
226227 entity_ids : list [int ],
227- fields : tuple [str , ...] = None ,
228228 is_active : ActiveStatusChoice = ActiveStatusChoice .NOT_SET ,
229+ fields : tuple [str , ...] = None ,
229230 options : dict [str , Any ] = None ,
230231 limit : Optional [int ] = None ,
231232 offset : Optional [int ] = None ,
@@ -234,8 +235,8 @@ def find(self,
234235 Find some rows from a model using their ID
235236
236237 :param entity_ids: Objects ID to query
237- :param fields: Tuple with the fields to include in the response
238238 :param is_active: Additional filter for active field
239+ :param fields: Tuple with the fields to include in the response
239240 :param options: Dictionary with options to use
240241 :param limit: Maximum number of results count
241242 :param offset: Starting record number to fetch the data
@@ -244,11 +245,10 @@ def find(self,
244245 """
245246 # Add filtered IDs
246247 filters = [['id' , CompareType .IN , entity_ids ]]
247- # Check for active records (Only active, only inactive or both)
248- if is_active == ActiveStatusChoice .BOTH :
249- filters .append (['active' , CompareType .IN , is_active ])
250- elif is_active != ActiveStatusChoice .NOT_SET :
251- filters .append (['active' , CompareType .EQUAL , is_active ])
248+ # Filter for active status
249+ self ._set_active (filters = filters ,
250+ is_active = is_active )
251+ # Set options
252252 if options is None :
253253 options = {}
254254 # Limit results only to selected fields
@@ -286,6 +286,7 @@ def filter(self,
286286 :param order: Ordering clause
287287 :return: List of dictionaries with the requested fields
288288 """
289+ # Set options
289290 if options is None :
290291 options = {}
291292 # Limit results only to selected fields
@@ -338,6 +339,7 @@ def search(self,
338339 :param order: Ordering clause
339340 :return: List of ID for the objects found
340341 """
342+ # Set options
341343 if options is None :
342344 options = {}
343345 # Set language for translated fields
@@ -364,6 +366,7 @@ def create(self,
364366 :param options: Dictionary with options to use
365367 :return: The ID of the newly created object
366368 """
369+ # Set options
367370 if options is None :
368371 options = {}
369372 # Set language for translated fields
@@ -385,6 +388,7 @@ def update(self,
385388 :param options: Dictionary with options to use
386389 :return: True if the records were updated
387390 """
391+ # Set options
388392 if options is None :
389393 options = {}
390394 # Set language for translated fields
@@ -405,13 +409,30 @@ def delete(self,
405409 :param options: Dictionary with options to use
406410 :return: True if the records were deleted
407411 """
412+ # Set options
408413 if options is None :
409414 options = {}
410415 # Request data and get results
411416 results = self .api .do_delete (entity_id = entity_id ,
412417 options = options )
413418 return results
414419
420+ def _set_active (self ,
421+ filters : list [Union [BooleanOperator , Filter ]],
422+ is_active : ActiveStatusChoice = ActiveStatusChoice .NOT_SET ,
423+ ) -> None :
424+ """
425+ Add a new filter for active records
426+
427+ :param filters: List of filters used for searching the data
428+ :return: None
429+ """
430+ if filters is not None :
431+ if is_active == ActiveStatusChoice .BOTH :
432+ filters .append (['active' , CompareType .IN , is_active ])
433+ elif is_active != ActiveStatusChoice .NOT_SET :
434+ filters .append (['active' , CompareType .EQUAL , is_active ])
435+
415436 def _set_options_language (self ,
416437 options : dict ) -> Optional [str ]:
417438 """
@@ -474,6 +495,7 @@ def get_fields(self,
474495 :param options: Dictionary with options to use
475496 :return: Dictionary with the requested fields
476497 """
498+ # Set options
477499 if options is None :
478500 options = {}
479501 # Limit results only to selected fields
0 commit comments