As message_notify can be done on empty recordset, message.res_id and message.model can be Falsy. During filtering on rating messages, we need to prevent the code to crash when filtering on those two properties and filter out messages that are not linked to any record. Task-2850521 (Knowledge: trash management) closes odoo/odoo#99436 Related: odoo/enterprise#30908 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>