Search code examples
odoo-11

How to display in a form/tree view a computed field with store = False ?Odoo 11


In Odoo 11, How to display in a form/tree view a computed field with store = False ?

For example :

The field Marge is a computed field with store=False

margin_pct = fields.Char(string = 'Marge', compute = _getmarginpct)

When the view is in modify mode the value of the field marge is displayed and modified as well

modify image

But when the view is in save mode or when we come back on the view the value of the field marge is not displayed

save image

Thanks for your answers.


Solution

  • You must be modifying the value of margin_pct field in an onchange function. Since this field is read only the values modified by on change functions will not be saved. So use depends instead of onchange and it should work.