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 | |
| 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')
43 files changed, 169 insertions, 117 deletions
diff --git a/addons/mail/i18n/ar.po b/addons/mail/i18n/ar.po index 6fb47d7a039..ec2e1704a29 100644 --- a/addons/mail/i18n/ar.po +++ b/addons/mail/i18n/ar.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/bg.po b/addons/mail/i18n/bg.po index e0f8ac68a2c..7cf6c62f616 100644 --- a/addons/mail/i18n/bg.po +++ b/addons/mail/i18n/bg.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/ca.po b/addons/mail/i18n/ca.po index acc918238bb..8452f97ba37 100644 --- a/addons/mail/i18n/ca.po +++ b/addons/mail/i18n/ca.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/da.po b/addons/mail/i18n/da.po index 02be31705ae..dcb518e5e17 100644 --- a/addons/mail/i18n/da.po +++ b/addons/mail/i18n/da.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/de.po b/addons/mail/i18n/de.po index 7f3f515b7b7..3a17c1c7294 100644 --- a/addons/mail/i18n/de.po +++ b/addons/mail/i18n/de.po @@ -15,7 +15,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/es.po b/addons/mail/i18n/es.po index 4ce2f14236a..2eeefed300e 100644 --- a/addons/mail/i18n/es.po +++ b/addons/mail/i18n/es.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/es_CR.po b/addons/mail/i18n/es_CR.po index 99c4e226de3..d77a89d0ad9 100644 --- a/addons/mail/i18n/es_CR.po +++ b/addons/mail/i18n/es_CR.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" "Language: es\n" diff --git a/addons/mail/i18n/es_MX.po b/addons/mail/i18n/es_MX.po index b090a2bc091..e02d9189a62 100644 --- a/addons/mail/i18n/es_MX.po +++ b/addons/mail/i18n/es_MX.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/es_PY.po b/addons/mail/i18n/es_PY.po index 66a51fe8d3f..b27ab59b721 100644 --- a/addons/mail/i18n/es_PY.po +++ b/addons/mail/i18n/es_PY.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/et.po b/addons/mail/i18n/et.po index 37531ea8e40..c2d984e6afc 100644 --- a/addons/mail/i18n/et.po +++ b/addons/mail/i18n/et.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/fi.po b/addons/mail/i18n/fi.po index 5f6d604df14..062474237d8 100644 --- a/addons/mail/i18n/fi.po +++ b/addons/mail/i18n/fi.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/fr.po b/addons/mail/i18n/fr.po index 43ab95b9708..cb2c0f461d0 100644 --- a/addons/mail/i18n/fr.po +++ b/addons/mail/i18n/fr.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/gl.po b/addons/mail/i18n/gl.po index d4a4b5591d1..ff0e8eb3d99 100644 --- a/addons/mail/i18n/gl.po +++ b/addons/mail/i18n/gl.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/hr.po b/addons/mail/i18n/hr.po index 67b3265932c..c2afc8e8794 100644 --- a/addons/mail/i18n/hr.po +++ b/addons/mail/i18n/hr.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/hu.po b/addons/mail/i18n/hu.po index b6ba5c8a5a2..645803483bc 100644 --- a/addons/mail/i18n/hu.po +++ b/addons/mail/i18n/hu.po @@ -13,7 +13,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/it.po b/addons/mail/i18n/it.po index df1846add33..d8b563e4e47 100644 --- a/addons/mail/i18n/it.po +++ b/addons/mail/i18n/it.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/ja.po b/addons/mail/i18n/ja.po index 2f48f28a20c..d135c31a420 100644 --- a/addons/mail/i18n/ja.po +++ b/addons/mail/i18n/ja.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/lt.po b/addons/mail/i18n/lt.po index aa35067747d..e6607b28764 100644 --- a/addons/mail/i18n/lt.po +++ b/addons/mail/i18n/lt.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/lv.po b/addons/mail/i18n/lv.po index cdbb8cc77d1..b04c87111e6 100644 --- a/addons/mail/i18n/lv.po +++ b/addons/mail/i18n/lv.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/mk.po b/addons/mail/i18n/mk.po index 7af2fc814fc..3aeeaa1392e 100644 --- a/addons/mail/i18n/mk.po +++ b/addons/mail/i18n/mk.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/mn.po b/addons/mail/i18n/mn.po index 58f3c2033a6..84ea4b5f700 100644 --- a/addons/mail/i18n/mn.po +++ b/addons/mail/i18n/mn.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/nl.po b/addons/mail/i18n/nl.po index b45eb3811d5..05c2574990f 100644 --- a/addons/mail/i18n/nl.po +++ b/addons/mail/i18n/nl.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/pl.po b/addons/mail/i18n/pl.po index a736f8090a5..6d53aabca12 100644 --- a/addons/mail/i18n/pl.po +++ b/addons/mail/i18n/pl.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/pt.po b/addons/mail/i18n/pt.po index 08cf2f9f49c..b36061318f0 100644 --- a/addons/mail/i18n/pt.po +++ b/addons/mail/i18n/pt.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/pt_BR.po b/addons/mail/i18n/pt_BR.po index aadfd7a2f0e..5645d15e121 100644 --- a/addons/mail/i18n/pt_BR.po +++ b/addons/mail/i18n/pt_BR.po @@ -15,7 +15,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/ro.po b/addons/mail/i18n/ro.po index d936acd5ba7..6a9911a6efa 100644 --- a/addons/mail/i18n/ro.po +++ b/addons/mail/i18n/ro.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/ru.po b/addons/mail/i18n/ru.po index 9b78a365a64..c0ae186a5bd 100644 --- a/addons/mail/i18n/ru.po +++ b/addons/mail/i18n/ru.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/sl.po b/addons/mail/i18n/sl.po index 6159bbc27d8..8dca991a1e2 100644 --- a/addons/mail/i18n/sl.po +++ b/addons/mail/i18n/sl.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/sr@latin.po b/addons/mail/i18n/sr@latin.po index 82449293b36..26dac34eda1 100644 --- a/addons/mail/i18n/sr@latin.po +++ b/addons/mail/i18n/sr@latin.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:49+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/sv.po b/addons/mail/i18n/sv.po index c7424144113..6007819e45d 100644 --- a/addons/mail/i18n/sv.po +++ b/addons/mail/i18n/sv.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/tr.po b/addons/mail/i18n/tr.po index 5b229fc179f..23dbab8d404 100644 --- a/addons/mail/i18n/tr.po +++ b/addons/mail/i18n/tr.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/zh_CN.po b/addons/mail/i18n/zh_CN.po index ee29695bff5..ba839ebc5bd 100644 --- a/addons/mail/i18n/zh_CN.po +++ b/addons/mail/i18n/zh_CN.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/i18n/zh_TW.po b/addons/mail/i18n/zh_TW.po index 5704914890f..f7b38e9c36c 100644 --- a/addons/mail/i18n/zh_TW.po +++ b/addons/mail/i18n/zh_TW.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-15 05:49+0000\n" +"X-Launchpad-Export-Date: 2013-03-16 05:48+0000\n" "X-Generator: Launchpad (build 16532)\n" #. module: mail diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index 40d1b2a7226..13db79e39f1 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -20,6 +20,8 @@ ############################################################################## from openerp.osv import osv, fields from openerp import tools, SUPERUSER_ID +from openerp.tools.translate import _ +from openerp.tools.mail import plaintext2html class mail_followers(osv.Model): """ mail_followers holds the data related to the follow mechanism inside @@ -105,6 +107,43 @@ class mail_notification(osv.Model): notify_pids.append(partner.id) return notify_pids + 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 = "" + 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, signature_company, plaintext=False, container_tag='div') + + return footer + def _notify(self, cr, uid, msg_id, partners_to_notify=None, context=None): """ Send by email the notification depending on the user preferences @@ -141,14 +180,11 @@ class mail_notification(osv.Model): # TDE FIXME: commented, to be improved in a future branch # quote_context = self.pool.get('mail.message').message_quote_context(cr, uid, msg_id, context=context) - mail_mail = self.pool.get('mail.mail') # add signature body_html = msg.body - # if quote_context: - # body_html = tools.append_content_to_html(body_html, quote_context, plaintext=False) - signature = msg.author_id and msg.author_id.user_ids and msg.author_id.user_ids[0].signature or '' - if signature: - body_html = tools.append_content_to_html(body_html, signature, plaintext=True, container_tag='div') + 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, 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') mail_values = { 'mail_message_id': msg.id, @@ -160,7 +196,7 @@ class mail_notification(osv.Model): mail_values['email_from'] = msg.email_from if msg.reply_to: mail_values['reply_to'] = msg.reply_to - + mail_mail = self.pool.get('mail.mail') email_notif_id = mail_mail.create(cr, uid, mail_values, context=context) try: return mail_mail.send(cr, uid, [email_notif_id], context=context) diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index 08892df3ccf..c415b46535d 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -167,15 +167,12 @@ class mail_mail(osv.Model): return 'Re: %s' % (mail.record_name) return mail.subject - def send_get_mail_body(self, cr, uid, mail, partner=None, context=None): - """ Return a specific ir_email body. The main purpose of this method - is to be inherited by Portal, to add a link for signing in, in + def send_get_mail_body_footer(self, cr, uid, mail, partner=None, context=None): + """ Return a specific footer for the ir_email body. The main purpose of this method + is to be inherited by Portal, to add modify the link for signing in, in each notification email a partner receives. - - :param browse_record mail: mail.mail browse_record - :param browse_record partner: specific recipient partner """ - body = mail.body_html + body_footer = "" # partner is a user, link to a related document (incentive to install portal) if partner and partner.user_ids and mail.model and mail.res_id \ and self.check_access_rights(cr, partner.user_ids[0].id, 'read', raise_exception=False): @@ -191,10 +188,23 @@ class mail_mail(osv.Model): 'id': mail.res_id, } url = urljoin(base_url, "?%s#%s" % (urlencode(query), urlencode(fragment))) - text = _("""<p>Access this document <a href="%s">directly in OpenERP</a></p>""") % url - body = tools.append_content_to_html(body, ("<div><p>%s</p></div>" % text), plaintext=False) + body_footer = _("""<small>Access this document <a style='color:inherit' href="%s">directly in OpenERP</a></small>""") % url except except_orm, e: pass + return body_footer + + def send_get_mail_body(self, cr, uid, mail, partner=None, context=None): + """ Return a specific ir_email body. The main purpose of this method + is to be inherited to add custom content depending on some module. + + :param browse_record mail: mail.mail browse_record + :param browse_record partner: specific recipient partner + """ + body = mail.body_html + + # add footer + body_footer = self.send_get_mail_body_footer(cr, uid, mail, partner=partner, context=context) + body = tools.append_content_to_html(body, body_footer, plaintext=False, container_tag='div') return body def send_get_mail_reply_to(self, cr, uid, mail, partner=None, context=None): diff --git a/addons/mail/res_users_view.xml b/addons/mail/res_users_view.xml index a119765e1ec..f49ff72194a 100644 --- a/addons/mail/res_users_view.xml +++ b/addons/mail/res_users_view.xml @@ -23,7 +23,7 @@ <field name="inherit_id" ref="base.view_users_form"/> <field name="arch" type="xml"> <data> - <field name="email" position="before"> + <field name="signature" position="before"> <field name="notification_email_send"/> </field> <field name="email" position="after"> diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 1e1142d592c..51306727a09 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -561,6 +561,14 @@ text-align: center; width:100%; } +.openerp .oe_followers button.oe_invite{ + margin: 5px 0; + padding: 2px 8px; + font-size: 12px; + text-shadow: none; + width: 100%; +} +.openerp .oe_followers button.oe_invite, .openerp .oe_followers button.oe_follower.oe_following{ color: white; background-color: #3465A4; @@ -614,9 +622,6 @@ margin-top: 12px; margin-bottom: 4px; } -.openerp .oe_followers .oe_invite{ - float: right; -} .openerp .oe_followers .oe_partner { height: 32px; overflow: hidden; diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 5dfc1946587..6fc2f0fdfcd 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -220,23 +220,16 @@ openerp_mail_followers = function(session, mail) { /** Display subtypes: {'name': default, followed} */ display_subtypes:function (data, id) { var self = this; - var subtype_list_ul = this.$('.oe_subtype_list'); - var records = []; - var nb_subtype = 0; - subtype_list_ul.empty(); - if (data[id]) { - records = data[id].message_subtype_data; - } - _(records).each(function (record) {nb_subtype++;}); - if (nb_subtype > 1) { - this.$('hr').show(); - _(records).each(function (record, record_name) { - record.name = record_name; - record.followed = record.followed || undefined; - $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( self.$('.oe_subtype_list') ); - }); - } else { - this.$('hr').hide(); + var $list = this.$('.oe_subtype_list'); + $list.empty().hide(); + var records = data[this.view.datarecord.id || this.view.dataset.ids[0]].message_subtype_data; + _(records).each(function (record, record_name) { + record.name = record_name; + record.followed = record.followed || undefined; + $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( self.$('.oe_subtype_list') ); + }); + if (_.size(records) > 1) { + $list.show(); } }, diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 459f13155a0..16bef174470 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -17,10 +17,9 @@ </t> <div class="oe_subtype_list"></div> </div> - <hr size="2"></hr> <div class='oe_follower_title_box'> <h4 class='oe_follower_title'>Followers</h4> - <a t-if="widget.view_is_editable" href='#' class="oe_invite">Add others</a> + <button t-if="widget.view_is_editable" href='#' class="oe_invite">Invite people</button> </div> <div class="oe_follower_list"></div> </div> diff --git a/addons/mail/tests/test_invite.py b/addons/mail/tests/test_invite.py index fe4b8ed10df..faa9fd55793 100644 --- a/addons/mail/tests/test_invite.py +++ b/addons/mail/tests/test_invite.py @@ -31,18 +31,18 @@ class test_invite(TestMailBase): # Do: create a mail_wizard_invite, validate it self._init_mock_build_email() context = {'default_res_model': 'mail.group', 'default_res_id': self.group_pigs_id} - mail_invite_id = mail_invite.create(cr, self.user_raoul_id, {'partner_ids': [(4, self.partner_bert_id)]}, context) + mail_invite_id = mail_invite.create(cr, self.user_raoul_id, {'partner_ids': [(4, self.partner_bert_id)], 'send_mail': True}, context) mail_invite.add_followers(cr, self.user_raoul_id, [mail_invite_id], {'default_model': 'mail.group', 'default_res_id': 0}) # 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 Pigs', - 'subject of invitation email is incorrect') - self.assertTrue('You have been invited to follow 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/tests/test_mail_features.py b/addons/mail/tests/test_mail_features.py index 7a442e9e4ac..5b4eb3b39ad 100644 --- a/addons/mail/tests/test_mail_features.py +++ b/addons/mail/tests/test_mail_features.py @@ -84,23 +84,6 @@ Sylvie class test_mail(TestMailBase): - def _mock_send_get_mail_body(self, *args, **kwargs): - # def _send_get_mail_body(self, cr, uid, mail, partner=None, context=None) - body = append_content_to_html(args[2].body_html, kwargs.get('partner').name if kwargs.get('partner') else 'No specific partner', plaintext=False) - return body - - def setUp(self): - super(test_mail, self).setUp() - - # Mock send_get_mail_body to test its functionality without other addons override - self._send_get_mail_body = self.registry('mail.mail').send_get_mail_body - self.registry('mail.mail').send_get_mail_body = self._mock_send_get_mail_body - - def tearDown(self): - # Remove mocks - self.registry('mail.mail').send_get_mail_body = self._send_get_mail_body - super(test_mail, self).tearDown() - def test_00_message_process(self): """ Testing incoming emails processing. """ cr, uid, user_raoul = self.cr, self.uid, self.user_raoul @@ -341,11 +324,15 @@ class test_mail(TestMailBase): _subject = 'Pigs' _mail_subject = 'Re: %s' % (group_pigs.name) _body1 = '<p>Pigs rules</p>' - _mail_body1 = '<p>Pigs rules</p>\n<div><p>Raoul</p></div>\n' - _mail_bodyalt1 = 'Pigs rules\nRaoul\n' + _mail_body1 = '<p>Pigs rules</p>' + _mail_signature1 = '<p>Raoul</p>' + _mail_bodyalt1 = 'Pigs rules\n' + _mail_signaturealt1 = '\nRaoul\n' _body2 = '<html>Pigs rules</html>' - _mail_body2 = '<div><p>Pigs rules</p></div>\n<div><p>Raoul</p></div>' - _mail_bodyalt2 = 'Pigs rules\nRaoul' + _mail_body2 = '<div><p>Pigs rules</p></div>' + _mail_signature2 = '<p>Raoul</p>' + _mail_bodyalt2 = 'Pigs rules\n' + _mail_signaturealt2 = '\nRaoul\n' _attachments = [('First', 'My first attachment'), ('Second', 'My second attachment')] # ---------------------------------------- @@ -366,12 +353,14 @@ class test_mail(TestMailBase): self.assertEqual(len(sent_emails), 2, 'sent_email number of sent emails incorrect') for sent_email in sent_emails: self.assertEqual(sent_email['subject'], _subject, 'sent_email subject incorrect') - self.assertTrue(sent_email['body'] in [_mail_body1 + '\nBert Tartopoils\n', _mail_body1 + '\nAdministrator\n'], - 'sent_email body incorrect') + self.assertIn(_mail_body1, sent_email['body'], 'sent_email body incorrect') + self.assertIn(_mail_signature1, sent_email['body'], 'sent_email body incorrect (no signature)') + self.assertIn("OpenERP", sent_email['body'], 'sent_email body incorrect (no OpenERP company)') # the html2plaintext uses etree or beautiful soup, so the result may be slighly different # depending if you have installed beautiful soup. - self.assertTrue(sent_email['body_alternative'] in [_mail_bodyalt1 + '\nBert Tartopoils\n', _mail_bodyalt1 + '\nAdministrator\n'], - 'sent_email body_alternative is incorrect') + self.assertIn(_mail_bodyalt1, sent_email['body_alternative'], 'sent_email body_alternative is incorrect') + self.assertIn(_mail_signaturealt1, sent_email['body_alternative'], 'sent_email body_alternative is incorrect (no signature)') + self.assertIn("OpenERP", sent_email['body_alternative'], 'sent_email body incorrect (no OpenERP company)') # Test: mail_message: notified_partner_ids = group followers message_pids = set([partner.id for partner in message1.notified_partner_ids]) test_pids = set([self.partner_admin_id, p_b_id, p_c_id]) @@ -405,7 +394,12 @@ class test_mail(TestMailBase): for sent_email in sent_emails: self.assertEqual(sent_email['subject'], _mail_subject, 'sent_email subject incorrect') self.assertIn(_mail_body2, sent_email['body'], 'sent_email body incorrect') - self.assertIn(_mail_bodyalt2, sent_email['body_alternative'], 'sent_email body_alternative incorrect') + self.assertIn(_mail_signature2, sent_email['body'], 'sent_email body incorrect (no signature)') + self.assertIn("OpenERP", sent_email['body'], 'sent_email body incorrect (no OpenERP company)') + # body_alternative + self.assertIn(_mail_bodyalt2, sent_email['body_alternative'], 'sent_email body_alternative is incorrect') + self.assertIn(_mail_signaturealt2, sent_email['body_alternative'], 'sent_email body_alternative is incorrect (no signature)') + self.assertIn("OpenERP", sent_email['body'], 'sent_email body incorrect (no OpenERP company)') # Test: mail_message: notified_partner_ids = group followers message_pids = set([partner.id for partner in message2.notified_partner_ids]) test_pids = set([self.partner_admin_id, p_b_id, p_c_id, p_d_id]) 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] diff --git a/addons/mail/wizard/invite_view.xml b/addons/mail/wizard/invite_view.xml index e957d546d37..2d550da2ecd 100644 --- a/addons/mail/wizard/invite_view.xml +++ b/addons/mail/wizard/invite_view.xml @@ -14,7 +14,8 @@ <field name="partner_ids" widget="many2many_tags_email" placeholder="Add contacts to notify..." context="{'force_email':True, 'show_email':True}"/> - <field name="message"/> + <field name="send_mail"/> + <field name="message" attrs="{'invisible': [('send_mail','!=',True)]}"/> </group> <footer> <button string="Add Followers" |
