mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
and here is the helper
This commit is contained in:
parent
bf679f185f
commit
69ee4ea14f
@ -667,3 +667,18 @@ def clean_decimal(number):
|
|||||||
return Decimal(0)
|
return Decimal(0)
|
||||||
|
|
||||||
return clean_number.quantize(Decimal(1)) if clean_number == clean_number.to_integral() else clean_number.normalize()
|
return clean_number.quantize(Decimal(1)) if clean_number == clean_number.to_integral() else clean_number.normalize()
|
||||||
|
|
||||||
|
|
||||||
|
def inheritors(cls):
|
||||||
|
"""
|
||||||
|
Return all classes that are subclasses from the supplied cls
|
||||||
|
"""
|
||||||
|
subcls = set()
|
||||||
|
work = [cls]
|
||||||
|
while work:
|
||||||
|
parent = work.pop()
|
||||||
|
for child in parent.__subclasses__():
|
||||||
|
if child not in subcls:
|
||||||
|
subcls.add(child)
|
||||||
|
work.append(child)
|
||||||
|
return subcls
|
||||||
|
Loading…
Reference in New Issue
Block a user