The Python Oracle

Odoo report field data is "Undefined" when expected False

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Droplet of life

--

Chapters
00:00 Odoo Report Field Data Is &Quot;Undefined&Quot; When Expected False
01:00 Accepted Answer Score 2
01:32 Thank you

--

Full question
https://stackoverflow.com/questions/4997...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #sql #report #odoo #odoo10

#avk47



ACCEPTED ANSWER

Score 2


It’s not ideal, but you could create a kind of computed copy/dummy field on res.partner that stores a Char version of the Boolean field.

Take this for example where the compute method just checks if the field is True and stores as 't' or 'f' depending on that.

is_customer_string = fields.Char('Is a Customer? (text)', compute='_compute_is_customer_string', store=True)

@api.multi
@api.depends('is_customer')
def _compute_is_customer_string(self):
    for partner in self:
        partner.is_customer_string = 't' if partner.is_customer else 'f'

Documentation on computed fields

Note: store=True is probably optional, but if you store the field, then you must use some depends field as a trigger to recompute. If you don't store the computed field, then the depends should be left off.