[MERGE][IMP] Enable HTML in emails signature
authorAmit Vora <avo@tinyerp.com>
Fri, 27 Jun 2014 09:31:24 +0000 (11:31 +0200)
committerRichard Mathot <rim@openerp.com>
Fri, 27 Jun 2014 09:31:24 +0000 (11:31 +0200)
Closes #801

addons/crm_partner_assign/crm_partner_assign_data.xml
addons/hr_recruitment/hr_recruitment_data.xml
addons/mail/mail_followers.py
addons/mail/tests/test_mail_features.py
addons/portal/portal_demo.xml
openerp/addons/base/base_data.xml
openerp/addons/base/res/res_users.py

index 284476c..cffee0a 100644 (file)
@@ -48,7 +48,7 @@
 <p>Thanks,</p>
 
 <pre>
-${ctx['partner_id'].user_id and ctx['partner_id'].user_id.signature or ''}
+${ctx['partner_id'].user_id and ctx['partner_id'].user_id.signature | safe or ''}
 </pre>
 % if not ctx['partner_id'].user_id:
 PS: It looks like you do not have an account manager assigned to you, please contact us.
index 5849a67..fdf5735 100644 (file)
@@ -33,7 +33,7 @@
         <p>If you want more details, feel free to contact us by phone.</p>
         <p>Kind regards,</p>
         <br/>
-         ${object.user_id and object.user_id.signature or ''}]]></field>
+         ${object.user_id and object.user_id.signature | safe or ''}]]></field>
     </record>
 
     <record id="applicant_interest" model="email.template">
@@ -51,7 +51,7 @@
         If I do not answer, please let me a message with some schedules to call you back.</p>
         <p>Kind regards,</p>
         <br/>
-         ${object.user_id.signature}]]></field>
+         ${object.user_id.signature | safe}]]></field>
     </record>
 
         <!--    HR Recruitment Source        -->
index 23e7f6a..2045353 100644 (file)
@@ -119,11 +119,10 @@ class mail_notification(osv.Model):
         # 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)
+            signature = user.signature
         else:
             signature = "--<br />%s" % user.name
-        footer = tools.append_content_to_html(footer, signature, plaintext=False, container_tag='p')
-
+        footer = tools.append_content_to_html(footer, signature, plaintext=False)
         # add company signature
         if user.company_id.website:
             website_url = ('http://%s' % user.company_id.website) if not user.company_id.website.lower().startswith(('http:', 'https:')) \
index 17836ea..2bf7bb9 100644 (file)
 from openerp.addons.mail.mail_mail import mail_mail
 from openerp.addons.mail.mail_thread import mail_thread
 from openerp.addons.mail.tests.common import TestMail
-from openerp.tools import mute_logger, email_split
+from openerp.tools import mute_logger, email_split, html2plaintext
 from openerp.tools.mail import html_sanitize
 
-
 class test_mail(TestMail):
 
     def test_000_alias_setup(self):
@@ -474,7 +473,7 @@ class test_mail(TestMail):
                             'message_post: notification email body alternative should contain the body')
             self.assertNotIn('<p>', sent_email['body_alternative'],
                             'message_post: notification email body alternative still contains html')
-            self.assertIn(user_raoul.signature, sent_email['body_alternative'],
+            self.assertIn(html2plaintext(user_raoul.signature), sent_email['body_alternative'],
                             'message_post: notification email body alternative should contain the sender signature')
             self.assertFalse(sent_email['references'],
                             'message_post: references should be False when sending a message that is not a reply')
@@ -545,7 +544,7 @@ class test_mail(TestMail):
                             'message_post: notification email body alternative should contain the body')
             self.assertNotIn('<p>', sent_email['body_alternative'],
                             'message_post: notification email body alternative still contains html')
-            self.assertIn(user_raoul.signature, sent_email['body_alternative'],
+            self.assertIn(html2plaintext(user_raoul.signature), sent_email['body_alternative'],
                             'message_post: notification email body alternative should contain the sender signature')
             self.assertIn(msg_message_id, sent_email['references'],
                             'message_post: notification email references lacks parent message message_id')
index ab48766..6cc1d6b 100644 (file)
@@ -18,8 +18,8 @@
             <field name="partner_id" ref="partner_demo_portal"/>
             <field name="login">portal</field>
             <field name="password">portal</field>
-            <field name="signature">--
-Mr Demo Portal</field>
+            <field name="signature"><![CDATA[<span>--<br/>
+Mr Demo Portal</span>]]></field>
             <!-- Avoid auto-including this user in any default group -->
             <field name="groups_id" eval="[(5,)]"/>
         </record>
index 728f1d4..5518b5c 100644 (file)
@@ -66,8 +66,8 @@
             <field name="partner_id" ref="base.partner_root"/>
             <field name="company_id" ref="main_company"/>
             <field name="company_ids" eval="[(4, ref('main_company'))]"/>
-            <field name="signature">--
-Administrator</field>
+            <field name="signature"><![CDATA[<span>--<br/>
+Administrator</span>]]></field>
         </record>
 
         <record id="main_partner" model="res.partner">
index c84ff05..c814155 100644 (file)
@@ -172,7 +172,7 @@ class res_users(osv.osv):
             help="Specify a value only when creating a user or if you're "\
                  "changing the user's password, otherwise leave empty. After "\
                  "a change of password, the user has to login again."),
-        'signature': fields.text('Signature'),
+        'signature': fields.html('Signature'),
         'active': fields.boolean('Active'),
         'action_id': fields.many2one('ir.actions.actions', 'Home Action', help="If specified, this action will be opened at log on for this user, in addition to the standard menu."),
         'groups_id': fields.many2many('res.groups', 'res_groups_users_rel', 'uid', 'gid', 'Groups'),