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.

18 lines
750 B

  1. # Copyright 2018 Tecnativa - Ernesto Tejeda
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import api, models, _
  4. from odoo.exceptions import ValidationError
  5. class MassMailingContactListRel(models.Model):
  6. _inherit = 'mail.mass_mailing.list_contact_rel'
  7. @api.constrains('contact_id', 'list_id')
  8. def _check_contact_id_partner_id_list_id(self):
  9. for rel in self:
  10. if rel.contact_id.partner_id:
  11. contacts = rel.list_id.contact_ids - rel.contact_id
  12. if rel.contact_id.partner_id in contacts.mapped('partner_id'):
  13. raise ValidationError(_("A partner cannot be multiple "
  14. "times in the same list"))