mirror of https://github.com/OCA/social.git
[FIX] mass_mailing_list_dynamic: Prevent ValidationError when merge contacts wizard related to dynamic and full sync list
parent
3cbf88b1f2
commit
7f3a3d6984
|
@ -11,7 +11,10 @@ class MassMailingContact(models.Model):
|
||||||
_inherit = "mail.mass_mailing.contact"
|
_inherit = "mail.mass_mailing.contact"
|
||||||
|
|
||||||
def _check_dynamic_full_sync_list(self, mailing_list):
|
def _check_dynamic_full_sync_list(self, mailing_list):
|
||||||
if mailing_list.dynamic and mailing_list.sync_method == "full":
|
if (
|
||||||
|
mailing_list.dynamic and mailing_list.sync_method == "full"
|
||||||
|
and not self.env.context.get("bypass_dynamic_list_check")
|
||||||
|
):
|
||||||
raise ValidationError(_(
|
raise ValidationError(_(
|
||||||
"Cannot edit manually contacts in a fully "
|
"Cannot edit manually contacts in a fully "
|
||||||
"synchronized list. Change its sync method or execute "
|
"synchronized list. Change its sync method or execute "
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||||
|
|
||||||
* Jairo Llopis <jairo.llopis@tecnativa.com>
|
* Jairo Llopis
|
||||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
* Pedro M. Baeza
|
||||||
* David Vidal <david.vidal@tecnativa.com>
|
* David Vidal
|
||||||
* Victor M.M. Torres <victor.martin@tecnativa.com>
|
* Victor M.M. Torres
|
||||||
|
* Victor Nartínez
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# Copyright 2017 Tecnativa - Jairo Llopis
|
# Copyright 2017 Tecnativa - Jairo Llopis
|
||||||
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
@ -150,3 +151,50 @@ class DynamicListCase(common.SavepointCase):
|
||||||
"dynamic": False,
|
"dynamic": False,
|
||||||
})
|
})
|
||||||
contact.list_ids = [(4, list2.id)]
|
contact.list_ids = [(4, list2.id)]
|
||||||
|
|
||||||
|
def test_partners_merge(self):
|
||||||
|
tag2 = self.tag.copy({
|
||||||
|
"name": "Tag 2"
|
||||||
|
})
|
||||||
|
self.list.sync_method = "full"
|
||||||
|
list2 = self.list.copy({
|
||||||
|
"name": "test list 2",
|
||||||
|
"sync_domain": repr([("category_id", "in", tag2.ids)]),
|
||||||
|
})
|
||||||
|
partner_1 = self.partners.create({
|
||||||
|
"name": "Demo 1",
|
||||||
|
"email": "demo1@demo.com",
|
||||||
|
"category_id": [(4, self.tag.id, False)],
|
||||||
|
})
|
||||||
|
partner_2 = self.partners.create({
|
||||||
|
"name": "Demo 2",
|
||||||
|
"email": "demo2@demo.com",
|
||||||
|
"category_id": [(4, self.tag.id, False), (4, tag2.id, False)],
|
||||||
|
})
|
||||||
|
self.list.action_sync()
|
||||||
|
list2.action_sync()
|
||||||
|
self.assertTrue(
|
||||||
|
partner_1.id in self.list.contact_ids.mapped('partner_id').ids
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
partner_2.id in self.list.contact_ids.mapped('partner_id').ids
|
||||||
|
)
|
||||||
|
self.assertFalse(
|
||||||
|
partner_1.id in list2.contact_ids.mapped('partner_id').ids
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
partner_2.id in list2.contact_ids.mapped('partner_id').ids
|
||||||
|
)
|
||||||
|
# Wizard partner merge (partner_1 + partner_2) in partner_i1
|
||||||
|
wizard = self.env["base.partner.merge.automatic.wizard"].create({
|
||||||
|
"state": "option",
|
||||||
|
"dst_partner_id": partner_1.id,
|
||||||
|
"partner_ids": [(4, partner_1.id), (4, partner_2.id)]
|
||||||
|
})
|
||||||
|
wizard.action_merge()
|
||||||
|
self.assertTrue(
|
||||||
|
partner_1.id in self.list.contact_ids.mapped('partner_id').ids
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
partner_1.id in list2.contact_ids.mapped('partner_id').ids
|
||||||
|
)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from . import mail_mass_mailing_load_filter
|
from . import mail_mass_mailing_load_filter
|
||||||
|
from . import partner_merge
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
|
class BasePartnerMergeAutomaticWizard(models.TransientModel):
|
||||||
|
_inherit = "base.partner.merge.automatic.wizard"
|
||||||
|
|
||||||
|
def _merge(self, partner_ids, dst_partner=None, extra_checks=True):
|
||||||
|
return super(
|
||||||
|
BasePartnerMergeAutomaticWizard, self.with_context(
|
||||||
|
bypass_dynamic_list_check=True
|
||||||
|
)
|
||||||
|
)._merge(
|
||||||
|
partner_ids=partner_ids, dst_partner=dst_partner, extra_checks=extra_checks,
|
||||||
|
)
|
Loading…
Reference in New Issue