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.

19 lines
677 B

8 years ago
  1. from odoo import models
  2. class Partner(models.Model):
  3. _inherit = "res.partner"
  4. def read(self, fields=None, load="_classic_read"):
  5. res = super(Partner, self).read(fields=fields, load=load)
  6. if fields and "message_ids" in fields:
  7. for vals in res:
  8. partner = self.browse(vals["id"])
  9. if not partner.is_company:
  10. continue
  11. domain = [
  12. ("model", "=", "res.partner"),
  13. ("res_id", "in", [partner.id] + partner.child_ids.ids),
  14. ]
  15. vals["message_ids"] = self.env["mail.message"].search(domain).ids
  16. return res