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.

33 lines
1.2 KiB

  1. # Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
  2. # Copyright 2019 Eugene Molotov <https://it-projects.info/team/em230418>
  3. # License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
  4. from odoo import api, models
  5. class MailMessage(models.Model):
  6. _inherit = "mail.message"
  7. # взято с mail_base
  8. @api.multi
  9. def write(self, values):
  10. if values.get("needaction_partner_ids"):
  11. if not values.get("partner_ids"):
  12. values["partner_ids"] = []
  13. for triplet in values.get("needaction_partner_ids"):
  14. if triplet[0] == 6:
  15. for i in triplet[2]:
  16. values["partner_ids"].append((4, i, False))
  17. return super(MailMessage, self).write(values)
  18. @api.multi
  19. def message_format(self):
  20. messages_values = super(MailMessage, self).message_format()
  21. for i in messages_values:
  22. if i["channel_ids"]:
  23. i["channel_names"] = (
  24. self.env["mail.channel"]
  25. .browse(i["channel_ids"])
  26. .mapped(lambda r: [r.id, "#" + r.display_name])
  27. )
  28. return messages_values