[IMP] mass_mailing_partner: Add test related to write with multi-partner

This commit is contained in:
Víctor Martínez 2021-02-11 16:07:22 +01:00 committed by emagdalenaC2i
parent f959dec61b
commit 6c0571c26d

View File

@ -1,7 +1,8 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Tecnativa - Pedro M. Baeza
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import ValidationError
@ -42,3 +43,19 @@ class ResPartnerCase(base.BaseCase):
self.check_mailing_contact_partner(contact)
with self.assertRaises(ValidationError):
self.partner.write({"email": False})
def test_write_res_partner_multi(self):
self.assertEqual(len(self.partner.category_id.ids), 2)
partner2 = self.partner.copy({"name": "Partner test 2"})
self.partner.write({"category_id": [(4, self.category_3.id)]})
self.assertEqual(len(self.partner.category_id.ids), 3)
self.assertEqual(len(partner2.category_id.ids), 2)
for partner in [self.partner, partner2]:
self.create_mailing_contact(
{"partner_id": partner.id, "list_ids": [[6, 0, [self.mailing_list.id]]]}
)
self.env["res.partner"].search(
[("id", "in", (self.partner.id, partner2.id))]
).write({"category_id": [(4, self.category_3.id)]})
self.assertEqual(len(self.partner.category_id.ids), 3)
self.assertEqual(len(partner2.category_id.ids), 3)