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.

56 lines
1.5 KiB

  1. from odoo import tools, api, fields, models
  2. # Copy Odoo's implementation in v12 back to v10 so that we have useful hooks to add what we need to later on.
  3. class CrmActivityReportOdoo(models.Model):
  4. _inherit = 'crm.activity.report'
  5. def _select(self):
  6. return """
  7. SELECT
  8. m.id,
  9. m.subtype_id,
  10. m.author_id,
  11. m.date,
  12. m.subject,
  13. l.id as lead_id,
  14. l.user_id,
  15. l.team_id,
  16. l.country_id,
  17. l.company_id,
  18. l.stage_id,
  19. l.partner_id,
  20. l.type as lead_type,
  21. l.active,
  22. l.probability
  23. """
  24. def _from(self):
  25. return """
  26. FROM mail_message AS m
  27. """
  28. def _join(self):
  29. return """
  30. JOIN crm_lead AS l ON m.res_id = l.id
  31. """
  32. def _where(self):
  33. return """
  34. WHERE
  35. m.model = 'crm.lead'
  36. """
  37. @api.model_cr
  38. def init(self):
  39. tools.drop_view_if_exists(self._cr, self._table)
  40. self._cr.execute("""
  41. CREATE OR REPLACE VIEW %s AS (
  42. %s
  43. %s
  44. %s
  45. %s
  46. )
  47. """ % (self._table, self._select(), self._from(), self._join(), self._where())
  48. )