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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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
<field name="int_field_name" attrs="{'invisible': [('int_field_name', '<=', 0)]}"/>
<field name="char_field_name" attrs="{'invisible': [('int_field_name', '>', 0)]}"/>
Change the field type to Char(), so that you can show integer values and also the text you prefer if it's negative.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up