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.

17 lines
645 B

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