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

I am new to odoo. I have a computed integer field that must be positive. But when negative, means that the field is not applicable to that situation. How do I display "N/A" when the field is negative?

Avatar
Discard
Best Answer

Hello Evans Djangbah,

There are 2 way to achieve this which are as follow.
1. You can change field type from 'Integer' to 'Char' so that you can Display 'N/A' when value is 0.
- when you try to access this field's value you can use below code.

value = int(self.field_name) if self.field_name != 'N/A' else 0
2. You can define one character field with default value 'N/A'. and you can use below xml code to display this fields.

Please find example in comment.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard

<field name="int_field_name" attrs="{'invisible': [('int_field_name', '<=', 0)]}"/>
<field name="char_field_name" attrs="{'invisible': [('int_field_name', '>', 0)]}"/>

Best Answer

Change the field type to Char(), so that you can show integer values and also the text you prefer if it's negative.

Avatar
Discard