Skip to content

Commit

Permalink
[FIX] mass_mailing_partner: wrong company implementation
Browse files Browse the repository at this point in the history
See issue OCA#776
  • Loading branch information
chienandalu committed Sep 22, 2021
1 parent bbeac63 commit 8390475
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
12 changes: 1 addition & 11 deletions mass_mailing_partner/models/mail_mass_mailing_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@ def write(self, vals):
super(MailMassMailingContact, 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 @@ -96,7 +86,7 @@ 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,
'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 @@ -104,10 +104,10 @@ def test_partners_merge(self):
'email': '[email protected]'
})
list_1 = self.create_mailing_list({
'name': 'List test 1'
'name': 'List test Partners Merge 1'
})
list_2 = self.create_mailing_list({
'name': 'List test 2'
'name': 'List test Partners Merge 2'
})
contact_1 = self.create_mailing_contact(
{
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',
'subscription_contact_ids': [
(0, 0, {'contact_id': contact_test_1.id}),
(0, 0, {'contact_id': contact_test_2.id}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_add_to_mail_list(self):
self.assertEqual(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 8390475

Please sign in to comment.