The Python Oracle

Odoo report field data is "Undefined" when expected False

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzling Curiosities

--

Chapters
00:00 Question
01:40 Accepted answer (Score 2)
02:37 Thank you

--

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

Question links:
[crm_opportunity_report]: https://github.com/odoo/odoo/blob/851356...
[line]: https://github.com/odoo/odoo/blob/2d12ae...

Accepted answer links:
[Documentation on computed fields]: https://www.odoo.com/documentation/10.0/...

--

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.