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.

38 lines
999 B

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. import logging
  4. def getlogger(name):
  5. filename = 'test.log'
  6. logger = logging.getLogger(name)
  7. handler = logging.FileHandler(filename)
  8. formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s: %(message)s')
  9. handler.setFormatter(formatter)
  10. logger.addHandler(handler)
  11. logger.setLevel(logging.DEBUG)
  12. return logger
  13. logger = getlogger(__name__)
  14. class res_partner(models.Model):
  15. _inherit = 'res.partner'
  16. mails_from = fields.Integer(compute="_mails_from")
  17. mails_to = fields.Integer(compute="_mails_to")
  18. @api.one
  19. def _mails_from(self):
  20. for r in self:
  21. letters = self.env['mail.message'].search([('partner_ids', 'in', r.id)])
  22. self.mails_from = len(letters)
  23. @api.one
  24. def _mails_to(self):
  25. for r in self:
  26. letters = self.env['mail.message'].search([('author_id', '=', r.id)])
  27. self.mails_to = len(letters)