You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
697 B

from odoo import api, models
class Partner(models.Model):
_inherit = "res.partner"
@api.multi
def read(self, fields=None, load="_classic_read"):
res = super(Partner, self).read(fields=fields, load=load)
if fields and "message_ids" in fields:
for vals in res:
partner = self.browse(vals["id"])
if not partner.is_company:
continue
domain = [
("model", "=", "res.partner"),
("res_id", "in", [partner.id] + partner.child_ids.ids),
]
vals["message_ids"] = self.env["mail.message"].search(domain).ids
return res