Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
921 Vistas

Hello, 

i have make customs report by formular and balance is negative so if i want to apply condition Field is negative balance so field = 0

how can i do it ? 

Best regard, KH

Avatar
Descartar
Mejor respuesta

Sure,

Balance if balance > 0 else 0

This means:

If balance is positive, show the balance , If balance is negative or zero, show 0.

<t t-esc="balance if balance > 0 else 0"/>

Or if you're using Python logic inside a computed field or report model:

self.filtered_balance = balance if balance > 0 else 0

This ensures negative values are converted to 0 in your report output.



I trust this information will be useful.

Avatar
Descartar
Mejor respuesta

Hi,

In custom reports using formulas, if you want to show a field only when its value is positive, and show zero when it's negative, you can use a conditional formula. For example, suppose your field is named balance. To achieve your requirement, "if balance is negative, then show 0; otherwise show the balance",  the formula would be something like:


In Python:


value = balance if balance >= 0 else 0


XML:


<t t-esc="balance if balance >= 0 else 0"/>


Hope it helps.

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
oct 25
2
1
oct 25
691
1
oct 25
173
2
oct 25
289
1
oct 25
310