Skip to Content
Menu
This question has been flagged
2 Replies
957 Views

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
0
Oct 25
2
0
Oct 25
166
2
Oct 25
291
2
Oct 25
2139
1
Oct 25
277