diff options
| -rw-r--r-- | addons/mail/tests/test_invite.py | 10 | ||||
| -rw-r--r-- | addons/mail/wizard/invite.py | 25 | ||||
| -rw-r--r-- | addons/portal/tests/test_portal.py | 10 |
3 files changed, 25 insertions, 20 deletions
diff --git a/addons/mail/tests/test_invite.py b/addons/mail/tests/test_invite.py index aef1456c45f..faa9fd55793 100644 --- a/addons/mail/tests/test_invite.py +++ b/addons/mail/tests/test_invite.py @@ -37,12 +37,12 @@ class test_invite(TestMailBase): # Test: Pigs followers should contain Admin, Bert self.group_pigs.refresh() follower_ids = [follower.id for follower in self.group_pigs.message_follower_ids] - self.assertEqual(set(follower_ids), set([self.partner_admin_id, self.partner_bert_id]), 'Pigs followers after invite is incorrect') + self.assertEqual(set(follower_ids), set([self.partner_admin_id, self.partner_bert_id]), 'invite: Pigs followers after invite is incorrect') # Test: (pretend to) send email and check subject, body self.assertEqual(len(self._build_email_kwargs_list), 1, 'sent email number incorrect, should be only for Bert') for sent_email in self._build_email_kwargs_list: - self.assertEqual(sent_email.get('subject'), 'Invitation to follow Discussion group document', - 'subject of invitation email is incorrect') - self.assertTrue('Raoul Grosbedon invited you to follow Discussion group document: Pigs' in sent_email.get('body'), - 'body of invitation email is incorrect') + self.assertEqual(sent_email.get('subject'), 'Invitation to follow Discussion group: Pigs', + 'invite: subject of invitation email is incorrect') + self.assertIn('Raoul Grosbedon invited you to follow Discussion group document: Pigs', sent_email.get('body'), + 'invite: body of invitation email is incorrect') diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index b8e44983a57..c3953818b4c 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -33,16 +33,18 @@ class invite_wizard(osv.osv_memory): def default_get(self, cr, uid, fields, context=None): result = super(invite_wizard, self).default_get(cr, uid, fields, context=context) user_name = self.pool.get('res.users').name_get(cr, uid, [uid], context=context)[0][1] - if 'message' in fields and result.get('res_model') and result.get('res_id'): + model = result.get('res_model') + res_id = result.get('res_id') + if 'message' in fields and model and res_id: ir_model = self.pool.get('ir.model') - model_ids = ir_model.search(cr, uid, [('model', '=', self.pool.get(result.get('res_model'))._name)], context=context) + model_ids = ir_model.search(cr, uid, [('model', '=', self.pool.get(model)._name)], context=context) model_name = ir_model.name_get(cr, uid, model_ids, context=context)[0][1] - document_name = self.pool.get(result.get('res_model')).name_get(cr, uid, [result.get('res_id')], context=context)[0][1] - message = _('<div>%s invited you to follow %s document: %s.</div>' % (user_name, model_name, document_name)) + document_name = self.pool.get(model).name_get(cr, uid, [res_id], context=context)[0][1] + message = _('<div><p>Hello,</p><p>%s invited you to follow %s document: %s.<p></div>') % (user_name, model_name, document_name) result['message'] = message elif 'message' in fields: - result['message'] = _('<div>%s invited you to follow a new document.</div>' % user_name) + result['message'] = _('<div><p>Hello,</p><p>%s invited you to follow a new document.</p></div>') % user_name return result _columns = { @@ -51,9 +53,12 @@ class invite_wizard(osv.osv_memory): help='Model of the followed resource'), 'res_id': fields.integer('Related Document ID', select=1, help='Id of the followed resource'), - 'partner_ids': fields.many2many('res.partner', string='Partners'), + 'partner_ids': fields.many2many('res.partner', string='Recipients', + help="List of partners that will be added as follower of the current document."), 'message': fields.html('Message'), - 'send_mail': fields.boolean('Send an email'), + 'send_mail': fields.boolean('Send Email', + help="If checked, the partners will receive an email warning they have been " + "added in the document's followers."), } def add_followers(self, cr, uid, ids, context=None): @@ -68,8 +73,8 @@ class invite_wizard(osv.osv_memory): ir_model = self.pool.get('ir.model') model_ids = ir_model.search(cr, uid, [('model', '=', model_obj._name)], context=context) model_name = ir_model.name_get(cr, uid, model_ids, context=context)[0][1] - - # send an email + + # send an email if option checked and if a message exists (do not send void emails) if wizard.send_mail and wizard.message: # add signature signature_company = self.pool.get('mail.notification').get_signature_footer(cr, uid, user_id=uid, res_model=wizard.res_model, res_id=wizard.res_id, context=context) @@ -82,7 +87,7 @@ class invite_wizard(osv.osv_memory): mail_id = mail_mail.create(cr, uid, { 'model': wizard.res_model, 'res_id': wizard.res_id, - 'subject': 'Invitation to follow %s document' % model_name, + 'subject': _('Invitation to follow %s: %s') % (model_name, document.name_get()[0][1]), 'body_html': '%s' % wizard.message, 'auto_delete': True, }, context=context) diff --git a/addons/portal/tests/test_portal.py b/addons/portal/tests/test_portal.py index a7b064997d7..07becf5cdd9 100644 --- a/addons/portal/tests/test_portal.py +++ b/addons/portal/tests/test_portal.py @@ -124,9 +124,9 @@ class test_portal(TestMailBase): # Test: (pretend to) send email and check subject, body self.assertEqual(len(self._build_email_kwargs_list), 1, 'sent email number incorrect, should be only for Bert') for sent_email in self._build_email_kwargs_list: - self.assertEqual(sent_email.get('subject'), 'Invitation to follow Discussion group document', - 'subject of invitation email is incorrect') - self.assertTrue('Administrator invited you to follow Discussion group document: Pigs' in sent_email.get('body'), - 'body of invitation email is incorrect') + self.assertEqual(sent_email.get('subject'), 'Invitation to follow Discussion group: Pigs', + 'invite: subject of invitation email is incorrect') + self.assertIn('Administrator invited you to follow Discussion group document: Pigs', sent_email.get('body'), + 'invite: body of invitation email is incorrect') self.assertTrue(partner_carine.signup_url in sent_email.get('body'), - 'body of invitation email does not contain signup url') + 'invite: body of invitation email does not contain signup url') |
