Utils#
This module contain a collection of utilities. It needs to be refactored into submodules based on their purpose. The state of this module is a mix of legacy code that needs to be properly sorted or removed.
- class odoo_tools.utils.ConfigParser(*args, **kwargs)[source]#
- odoo_tools.utils.from_bool(value)[source]#
Convert a bool into a string value.
- Parameters:
value (
bool
) – A boolean like value.- Returns:
A text representation of a boolean value.
- Return type:
bool
- odoo_tools.utils.obj_set(delimiter=', ', container=<class 'list'>, item_type=<class 'str'>)[source]#
Convert a CSV value into a set of values.
- Parameters:
delimiter (str) – the delimiter of the CSV value.
container (callable) – The type of the container of the set. Defaults to
list
.item_type (callable) – The type of the value to be mapped to. Defaults to
str
.
- Returns:
The mapped value of the csv.
- Return type:
container<item_type>
- odoo_tools.utils.random_string(stringLength=10)[source]#
Generate a random string of fixed length.
- Parameters:
stringLength (int) – The length of the string to be generated. Defaults to 10.
- odoo_tools.utils.to_bool(value)[source]#
Convert a string into a bool value.
The value will be true if its a text representation that is a caseless version of ‘true’.
Any other value will be False.
- Parameters:
value (
str
) – A text representation of a boolean. The value must be true to be true. Any other value will be interpreted as False.- Returns:
A True or False representation of the text input.
- Return type:
bool