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.

21 lines
724 B

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