diff options
| author | Thibault Delavallée <tde@openerp.com> | 2013-03-18 13:20:27 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2013-03-18 13:20:27 +0100 |
| commit | 7e696dfdcbb6f3d8d834d17963af5edda4756903 (patch) | |
| tree | 61d9249d5135a083a8916ec497ef8e39e859a8c7 /addons/mail/wizard/invite.py | |
| parent | 660b94845a72a06d55f5a88ffd82087e46823eca (diff) | |
| parent | 00bb2273d949c71e5540776345cc4faede5c05f4 (diff) | |
[MERGE] Sync with trunk and latest mail changes.
bzr revid: tde@openerp.com-20130318122027-l570iyzlljshz4ne
Diffstat (limited to 'addons/mail/wizard/invite.py')
| -rw-r--r-- | addons/mail/wizard/invite.py | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index 687249a6445..2eb48f3d998 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -32,12 +32,19 @@ 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) - if 'message' in fields and result.get('res_model') and result.get('res_id'): - document_name = self.pool.get(result.get('res_model')).name_get(cr, uid, [result.get('res_id')], context=context)[0][1] - message = _('<div>You have been invited to follow %s.</div>' % document_name) + user_name = self.pool.get('res.users').name_get(cr, uid, [uid], context=context)[0][1] + 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(model)._name)], context=context) + model_name = ir_model.name_get(cr, uid, model_ids, context=context)[0][1] + + 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>You have been invited to follow a new document.</div>') + result['message'] = _('<div><p>Hello,</p><p>%s invited you to follow a new document.</p></div>') % user_name return result _columns = { @@ -46,8 +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 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): @@ -59,13 +70,16 @@ class invite_wizard(osv.osv_memory): new_follower_ids = [p.id for p in wizard.partner_ids if p not in document.message_follower_ids] model_obj.message_subscribe(cr, uid, [wizard.res_id], new_follower_ids, context=context) - # send an email - if wizard.message: + 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 if option checked and if a message exists (do not send void emails) + if wizard.send_mail and wizard.message: # add signature - user_id = self.pool.get("res.users").read(cr, uid, [uid], fields=["signature"], context=context)[0] - signature = user_id and user_id["signature"] or '' - if signature: - wizard.message = tools.append_content_to_html(wizard.message, signature, plaintext=True, container_tag='div') + # FIXME 8.0: use notification_email_send, send a wall message and let mail handle email notification + message box + 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) + wizard.message = tools.append_content_to_html(wizard.message, signature_company, plaintext=False, container_tag='div') # send mail to new followers # the invite wizard should create a private message not related to any object -> no model, no res_id @@ -73,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.name_get()[0][1], + 'subject': _('Invitation to follow %s: %s') % (model_name, document.name_get()[0][1]), 'body_html': '%s' % wizard.message, 'auto_delete': True, 'recipient_ids': [(4, id) for id in new_follower_ids] |
