I have modified crm_opportunity_report :
added a boolean field is_customer = fields.Boolean('Is customer', readonly=True)
added a field to the view
CREATE VIEW crm_opportunity_report AS (
SELECT
<...>omitted<...>
rp.customer as is_customer
FROM
"crm_lead" c
LEFT JOIN "res_partner" rp ON rp.id = c.partner_id
<...>omitted<...>
GROUP BY c.id, stage.name, is_customer
After this in the report when I click "+" and choose "Is customer" sometimes value Undefined appears as a value for it.
Tried this: COALESCE(rp.customer, FALSE) as is_customer (and the same in Group by) but "Undefined" is still present.
How in Odoo report I can make Undefined mean False so that when it's "Undefined" appears "False"?
Note: when debugging with Firefox I can observe that from the server comes (jsonrpc) data with either "is_customer: false" or "is_customer: true" on items of report. But somehow those items that have "is_customer: false" on the report view are displayed as if "is_customer: Undefined".
Update
Somewhat accidentally I stumbled upon this line
if (value === false) return _t("Undefined");
What might be the reason behind this logic: 'if value is false return "Undefined"'?
Funny part, I can add if (value === true) return _t("Whatever"); :)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With