Browse Source

fixup! fixup! fixup! fixup! fixup! fixup! [ADD][mail_parent_recipient][10] Add module to use mail of first partner

pull/329/head
Tonow-c2c 6 years ago
parent
commit
23ea229ed7
  1. 9
      mail_parent_recipient/models/mail_template.py
  2. 3
      mail_parent_recipient/readme/CREDITS.rst
  3. 4
      mail_parent_recipient/readme/DESCRIPTION.rst
  4. 16
      mail_parent_recipient/tests/test_mail_parent_recipient.py

9
mail_parent_recipient/models/mail_template.py

@ -10,11 +10,10 @@ class MailTemplate(models.Model):
@api.multi
def generate_recipients(self, results, res_ids):
"""
Modify the code that set the default recipient in an email to the first
partner having an email set following the parents tree.
If no parent with an email is found,
it reverts to the popup asking to set an email for the current partner
"""Use partner's parent email as recipient.
Walk up the hierarchy of recipient partners via `parent_id`
and pick the 1st one having an email.
"""
results = super(MailTemplate, self).generate_recipients(
results,

3
mail_parent_recipient/readme/CREDITS.rst

@ -1,4 +1,3 @@
The development of this module has been financially supported by:
* Camptocamp Thomas Nowicki
* Camptocamp

4
mail_parent_recipient/readme/DESCRIPTION.rst

@ -1,3 +1 @@
This modules set the default recipient in an email to the first partner having
an email set following the parents tree. If no parent with an email is found,
it reverts to the popup asking to set an email for the current partner.
This modules add the fact to use partner's parent email as recipient.

16
mail_parent_recipient/tests/test_mail_parent_recipient.py

@ -77,10 +77,7 @@ class TestMailTemplate(TestMail):
return recipients
def test_1_mail_send_to_partner_no_mail(self):
"""
Mail should only send with company mail
even if is sended to partner_no_mail
"""
"""Use company mail if recipient partner has no email."""
recipients = self.create_mail_composer(self.partner_no_mail.id)
self.assertEqual(recipients.email, self.company_test.email)
@ -88,10 +85,7 @@ class TestMailTemplate(TestMail):
self.assertNotEqual(recipients.email, self.partner_with_mail.email)
def test_2_mail_send_to_partner_with_mail(self):
"""
Mail should only send with company mail
even if is sended to partner_with_mail
"""
"""Use partner mail if recipient partner has an email."""
recipients = self.create_mail_composer(self.partner_with_mail.id)
self.assertNotEqual(recipients.email, self.company_test.email)
@ -99,10 +93,8 @@ class TestMailTemplate(TestMail):
self.assertEqual(recipients.email, self.partner_with_mail.email)
def test_3_mail_send_to_company_test(self):
"""
Mail should only send with company mail
"""
recipients = self.create_mail_composer(self.partner_no_mail.id)
"""Use company mail if recipient is the company."""
recipients = self.create_mail_composer(self.company_test.id)
self.assertEqual(recipients.email, self.company_test.email)
self.assertNotEqual(recipients.email, self.partner_no_mail.email)

Loading…
Cancel
Save