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.

30 lines
966 B

  1. # Copyright 2018 David Vidal <david.vidal@tecnativa.com>
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class MailMassMailing(models.Model):
  5. _inherit = "mail.mass_mailing.contact"
  6. # Recover the old Many2one field so we can set a contact by list
  7. mailing_list_id = fields.Many2one(
  8. 'mail.mass_mailing.list',
  9. string='Mailing List',
  10. ondelete='cascade',
  11. compute="_compute_mailing_list_id",
  12. inverse="_inverse_mailing_list_id",
  13. search="_search_mailing_list_id",
  14. )
  15. @api.depends('list_ids')
  16. def _compute_mailing_list_id(self):
  17. for contact in self:
  18. contact.mailing_list_id = contact.list_ids[:1]
  19. def _inverse_mailing_list_id(self):
  20. for contact in self:
  21. contact.list_ids = contact.mailing_list_id
  22. def _search_mailing_list_id(self, operator, value):
  23. return [('list_ids', operator, value)]