summaryrefslogtreecommitdiff
path: root/addons/mass_mailing/models
diff options
context:
space:
mode:
authorijas ahammed <ija@odoo.com>2021-02-25 09:24:23 +0000
committerDharmraj Jhala <dja@odoo.com>2021-03-01 09:27:25 +0000
commitb92ebf3a47b7b1263669ac020ac8c213027400ea (patch)
tree1a4e1fe130554302473d39b4fbbb984b349c07f0 /addons/mass_mailing/models
parentebadf16c7c38ca52ec4c5ce871c2584aaa98b91d (diff)
[FIX] mass_mailing: allow duplicating mailing contact from mailing list
Before this commit: While trying to duplicate a mailing contact within particular mailing list, it throws an user error saysing that 'A mailing contact cannot subscribe to the same mailing list multiple times.' After this commit: User can duplicate a mailing contact from a mailing list without the user error. In this case, we simply remove the default_list_ids from the context, because all the mailing lists will be simply be copied over from the existing contact and so we don't have to re-add the default ones. closes odoo/odoo#66827 Task-id: 2431344 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/mass_mailing/models')
-rw-r--r--addons/mass_mailing/models/mailing_contact.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/addons/mass_mailing/models/mailing_contact.py b/addons/mass_mailing/models/mailing_contact.py
index 5d74fd511f9..27ce87a24ff 100644
--- a/addons/mass_mailing/models/mailing_contact.py
+++ b/addons/mass_mailing/models/mailing_contact.py
@@ -140,6 +140,15 @@ class MassMailingContact(models.Model):
return super(MassMailingContact, self.with_context(default_list_ids=False)).create(vals_list)
+ @api.returns('self', lambda value: value.id)
+ def copy(self, default=None):
+ """ Cleans the default_list_ids while duplicating mailing contact in context of
+ a mailing list because we already have subscription lists copied over for newly
+ created contact, no need to add the ones from default_list_ids again """
+ if self.env.context.get('default_list_ids'):
+ self = self.with_context(default_list_ids=False)
+ return super().copy(default)
+
@api.model
def name_create(self, name):
name, email = self.get_name_email(name)