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
684 B

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