Skip to content

Commit

Permalink
Merge PR #778 into 13.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Sep 22, 2021
2 parents 24ff4eb + 21848e6 commit a4c0995
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
15 changes: 2 additions & 13 deletions mass_mailing_partner/models/mailing_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,6 @@ def write(self, vals):
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]]
Expand All @@ -95,7 +83,8 @@ def _prepare_partner(self):
"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(),
}

Expand Down
4 changes: 2 additions & 2 deletions mass_mailing_partner/tests/test_mail_mass_mailing_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def test_onchange_partner(self):
def test_partners_merge(self):
partner_1 = self.create_partner({"name": "Demo 1", "email": "[email protected]"})
partner_2 = self.create_partner({"name": "Demo 2", "email": "[email protected]"})
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,
Expand Down
4 changes: 2 additions & 2 deletions mass_mailing_partner/tests/test_mail_mass_mailing_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_create_mass_mailing_list(self):
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)],
}
)
Expand All @@ -33,7 +33,7 @@ def test_create_mass_mailing_list_with_subscription(self):
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)],
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_add_to_mail_list(self):
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)
Expand Down

0 comments on commit a4c0995

Please sign in to comment.