diff options
| author | Thibault Delavallée <tde@openerp.com> | 2013-03-15 12:04:55 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2013-03-15 12:04:55 +0100 |
| commit | 627ebc4a731b8c0aa9308e55ed73a4e6c8eac2a1 (patch) | |
| tree | 754cb05fe902e7485ae5d3975e3e5c8653e66f64 | |
| parent | 646c83c250153822db477a29e8134830a58ecb09 (diff) | |
[CLEAN] mail_followers: cleaned code of get_signature_footer: same feature, but a bit less code.
bzr revid: tde@openerp.com-20130315110455-7ho0djpjlkbap6l1
| -rw-r--r-- | addons/mail/mail_followers.py | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index afdef5269bf..db48db2ec61 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -102,37 +102,41 @@ class mail_notification(osv.Model): notify_pids.append(partner.id) return notify_pids - def get_signature_footer(self, cr, uid, user_id=None, res_model=None, res_id=None, context=None): - """ Return the footer with signature - On bottom of the message, add the user's company link or the user name and a link to oepenerp + def get_signature_footer(self, cr, uid, user_id, res_model=None, res_id=None, context=None): + """ Format a standard footer for notification emails (such as pushed messages + notification or invite emails). + Format: + <p>--<br /> + Administrator + </p> + <div> + <small>Send by <a ...>Your Company</a> using <a ...>OpenERP</a>.</small> OR + <small>Send by Administrator using <a ...>OpenERP</a>.</small> + </div> """ footer = "" - company = None - user = None - - if user_id: - users = self.pool.get("res.users").browse(cr, uid, [user_id], context=context) - user = users and users[0] or None - - if user: - if user.signature: - signature = plaintext2html(user.signature) - else: - signature = "--<br>%s" % user.name - footer = tools.append_content_to_html(footer, signature, plaintext=False, container_tag='p') - - if user.company_id: - company = user.company_id.website and "<a style='color:inherit' href='%s'>%s</a>" % (user.company_id.website, user.company_id.name) or user.company_id.name - else: - company = user.name - - if company: - signature_company = _('Send by %(company)s using %(openerp)s.' % { + if not user_id: + return footer + + # add user signature + user = self.pool.get("res.users").browse(cr, SUPERUSER_ID, [user_id], context=context)[0] + if user.signature: + signature = plaintext2html(user.signature) + else: + signature = "--<br />%s" % user.name + footer = tools.append_content_to_html(footer, signature, plaintext=False, container_tag='p') + + # add company signature + if user.company_id: + company = user.company_id.website and "<a style='color:inherit' href='%s'>%s</a>" % (user.company_id.website, user.company_id.name) or user.company_id.name + else: + company = user.name + signature_company = _('<small>Send by %(company)s using %(openerp)s.</small>' % { 'company': company, 'openerp': "<a style='color:inherit' href='https://www.openerp.com/'>OpenERP</a>" }) - footer = tools.append_content_to_html(footer, "<small>%s</small>" % signature_company, plaintext=False, container_tag='div') - + footer = tools.append_content_to_html(footer, signature_company, plaintext=False, container_tag='div') + return footer def _notify(self, cr, uid, msg_id, context=None): @@ -155,7 +159,7 @@ class mail_notification(osv.Model): # add signature body_html = msg.body user_id = msg.author_id and msg.author_id.user_ids and msg.author_id.user_ids[0] and msg.author_id.user_ids[0].id or None - signature_company = self.get_signature_footer(cr, uid, user_id=user_id, res_model=msg.model, res_id=msg.res_id, context=context) + signature_company = self.get_signature_footer(cr, uid, user_id, res_model=msg.model, res_id=msg.res_id, context=context) body_html = tools.append_content_to_html(body_html, signature_company, plaintext=False, container_tag='div') # email_from: partner-user alias or partner email or mail.message email_from |
