[FIX] mass_mailing_partner: wrong company implementation
See issue https://github.com/OCA/social/issues/776
This commit is contained in:
parent
9314b69963
commit
8a3d9bef2d
@ -73,18 +73,6 @@ class MailingContact(models.Model):
|
||||
super(MailingContact, contact).write(new_vals)
|
||||
return True
|
||||
|
||||
def _get_company(self):
|
||||
company_id = False
|
||||
if self.company_name:
|
||||
company_id = (
|
||||
self.env["res.company"].search([("name", "=", self.company_name)]).id
|
||||
)
|
||||
if not company_id:
|
||||
company_id = (
|
||||
self.env["res.company"].create({"name": self.company_name}).id
|
||||
)
|
||||
return company_id
|
||||
|
||||
def _get_categories(self):
|
||||
ca_ids = self.tag_ids.ids + self.list_ids.mapped("partner_category.id")
|
||||
return [[6, 0, ca_ids]]
|
||||
@ -95,7 +83,8 @@ class MailingContact(models.Model):
|
||||
"email": self.email,
|
||||
"country_id": self.country_id.id,
|
||||
"title": self.title_id.id,
|
||||
"company_id": self._get_company(),
|
||||
"company_name": self.company_name,
|
||||
"company_id": False,
|
||||
"category_id": self._get_categories(),
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,8 @@ class MailMassMailingContactCase(base.BaseCase):
|
||||
def test_partners_merge(self):
|
||||
partner_1 = self.create_partner({"name": "Demo 1", "email": "demo1@demo.com"})
|
||||
partner_2 = self.create_partner({"name": "Demo 2", "email": "demo2@demo.com"})
|
||||
list_1 = self.create_mailing_list({"name": "List test 1"})
|
||||
list_2 = self.create_mailing_list({"name": "List test 2"})
|
||||
list_1 = self.create_mailing_list({"name": "List test Partners Merge 1"})
|
||||
list_2 = self.create_mailing_list({"name": "List test Partners Merge 2"})
|
||||
contact_1 = self.create_mailing_contact(
|
||||
{
|
||||
"email": partner_1.email,
|
||||
|
@ -18,7 +18,7 @@ class MailMassMailingListCase(base.BaseCase):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.create_mailing_list(
|
||||
{
|
||||
"name": "List test 3",
|
||||
"name": "List test Create Mailing List",
|
||||
"contact_ids": [(6, 0, (contact_test_1 | contact_test_2).ids)],
|
||||
}
|
||||
)
|
||||
@ -33,7 +33,7 @@ class MailMassMailingListCase(base.BaseCase):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.create_mailing_list(
|
||||
{
|
||||
"name": "List test 3",
|
||||
"name": "List test Creat List With Subscription",
|
||||
"contact_ids": [(4, contact_test_1.id), (4, contact_test_2.id)],
|
||||
}
|
||||
)
|
||||
|
@ -29,7 +29,7 @@ class PartnerMailListWizardCase(base.BaseCase):
|
||||
self.partner.mass_mailing_contact_ids.list_ids, self.mailing_list
|
||||
)
|
||||
|
||||
list_2 = self.create_mailing_list({"name": "New list"})
|
||||
list_2 = self.create_mailing_list({"name": "Test Add to List"})
|
||||
wizard.mail_list_id = list_2
|
||||
wizard.add_to_mail_list()
|
||||
self.assertEqual(len(self.partner.mass_mailing_contact_ids), 1)
|
||||
|
Loading…
Reference in New Issue
Block a user