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.

31 lines
825 B

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class ResPartner(models.Model):
  4. _inherit = 'res.partner'
  5. mails_to = fields.Integer(compute="_mails_to")
  6. mails_from = fields.Integer(compute="_mails_from")
  7. @api.multi
  8. def _mails_to(self):
  9. for r in self:
  10. r._mails_to_one(self)
  11. @api.multi
  12. def _mails_to_one(self):
  13. self.ensure_one()
  14. for r in self:
  15. r.mails_to = self.env['mail.message'].sudo().search_count([('partner_ids', 'in', r.id)])
  16. @api.multi
  17. def _mails_from(self):
  18. for r in self:
  19. r._mails_from_one(self)
  20. @api.multi
  21. def _mails_from_one(self):
  22. self.ensure_one()
  23. for r in self:
  24. r.mails_from = self.env['mail.message'].sudo().search_count([('author_id', '=', r.id)])