hello guys, i have a problem to override the float fields about digit decimals, i want the digit disappears globally if the value is zero like examples:
5.660 -> 5.66
5.00 -> 5
7.10 -> 7.1
I'm already trying to override methods in Class Float(Field) and nothing is happening:
convert_to_column
convert_to_cache
this is my code:
from odoo.fields import Float
def new_float_convert_to_column(self, value, record, values=None):
print(value, 'VALUE FLOAT MIAW')
print('miaw')
miaw1 = '{:g}'.format(float(value or 0.0))
result = float(miaw1)
return result
def new_float_convert_to_cache(self, value, record, validate=True):
value = float(value or 0.0)
if not validate:
return value
miaw = '{:g}'.format(value)
result = float(miaw)
return result
Float.convert_to_column = new_float_convert_to_column
Float.convert_to_cache = new_float_convert_to_cache
when i try to print the result it works! but on the odoo GUI still show 150.10 when it should be 150.1
thanks in advance
can i do that?
or am i do it wrong?