Thibault Delavallée (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/7.0-chatter-emails-doclink-tde into lp:openobject-addons/7.0.
Requested reviews: OpenERP Core Team (openerp) For more details, see: https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-chatter-emails-doclink-tde/+merge/141381 -- https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-chatter-emails-doclink-tde/+merge/141381 Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/7.0-chatter-emails-doclink-tde.
=== modified file 'mail/mail_followers.py' --- mail/mail_followers.py 2012-12-21 19:41:48 +0000 +++ mail/mail_followers.py 2012-12-27 20:31:23 +0000 @@ -75,13 +75,6 @@ if not cr.fetchone(): cr.execute('CREATE INDEX mail_notification_partner_id_read_starred_message_id ON mail_notification (partner_id, read, starred, message_id)') - def create(self, cr, uid, vals, context=None): - """ Override of create to check that we can not create a notification - for a message the user can not read. """ - if self.pool.get('mail.message').check_access_rights(cr, uid, 'read'): - return super(mail_notification, self).create(cr, uid, vals, context=context) - return False - def get_partners_to_notify(self, cr, uid, message, context=None): """ Return the list of partners to notify, based on their preferences. === modified file 'mail/mail_mail.py' --- mail/mail_mail.py 2012-12-18 17:55:47 +0000 +++ mail/mail_mail.py 2012-12-27 20:31:23 +0000 @@ -160,6 +160,19 @@ """ return mail.body_html + def send_get_mail_reply_to(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 + each notification email a partner receives. + + :param browse_record mail: mail.mail browse_record + :param browse_record partner: specific recipient partner + """ + if not mail.model or not mail.res_id: + return False + doc = self.pool.get(mail.model).browse(cr, SUPERUSER_ID, res_id, context=context) + if doc. + def send_get_email_dict(self, cr, uid, mail, partner=None, context=None): """ Return a dictionary for specific email values, depending on a partner, or generic to the whole recipients given by mail.email_to. @@ -169,6 +182,7 @@ """ body = self.send_get_mail_body(cr, uid, mail, partner=partner, context=context) subject = self.send_get_mail_subject(cr, uid, mail, partner=partner, context=context) + reply_to = self.send_get_mail_reply_to(cr, uid, mail, partner=partner, context=context) body_alternative = tools.html2plaintext(body) email_to = [partner.email] if partner else tools.email_split(mail.email_to) return { @@ -176,6 +190,7 @@ 'body_alternative': body_alternative, 'subject': subject, 'email_to': email_to, + 'reply_to': reply_to, } def send(self, cr, uid, ids, auto_commit=False, recipient_ids=None, context=None): === modified file 'mail/wizard/invite.py' --- mail/wizard/invite.py 2012-12-21 13:39:28 +0000 +++ mail/wizard/invite.py 2012-12-27 20:31:23 +0000 @@ -69,8 +69,6 @@ 'subject': 'Invitation to follow %s' % document.name_get()[0][1], 'body_html': '%s' % wizard.message, 'auto_delete': True, - 'res_id': False, - 'model': False, }, context=context) mail_mail.send(cr, uid, [mail_id], recipient_ids=[follower_id], context=context) return {'type': 'ir.actions.act_window_close'} === modified file 'mail/wizard/invite_view.xml' --- mail/wizard/invite_view.xml 2012-12-21 13:39:28 +0000 +++ mail/wizard/invite_view.xml 2012-12-27 20:31:23 +0000 @@ -13,7 +13,7 @@ <field name="res_id" invisible="1"/> <field name="partner_ids" widget="many2many_tags_email" placeholder="Add contacts to notify..." - context="{'force_email':True}"/> + context="{'force_email':True, 'show_email':True}"/> <field name="message"/> </group> <footer> === modified file 'portal/mail_mail.py' --- portal/mail_mail.py 2012-12-12 12:55:18 +0000 +++ portal/mail_mail.py 2012-12-27 20:31:23 +0000 @@ -19,6 +19,9 @@ # ############################################################################## +from urllib import urlencode +from urlparse import urljoin + from openerp import SUPERUSER_ID from openerp.osv import osv from openerp.tools import append_content_to_html @@ -39,6 +42,33 @@ if partner: context = dict(context or {}, signup_valid=True) partner = self.pool.get('res.partner').browse(cr, SUPERUSER_ID, partner.id, context=context) - text = _("""Access your personal documents through <a href="%s">our Customer Portal</a>""") % partner.signup_url + text = '' + # private message + print mail.model, mail.res_id + if not mail.model or not mail.res_id: + text = _("""<p>Access your messages through <a href="%s">our Customer Portal</a></p>""") % partner.signup_url + # partner is also an user: add a link if read access to the document + elif partner.user_ids and self.check_access_rights(cr, partner.user_ids[0].id, 'read', raise_exception=False): + related_user = partner.user_ids[0] + try: + print 'cacapoum1' + self.check_access_rule(cr, related_user.id, [mail.res_id], 'read', context=context) + print 'cacapoum2' + base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') + print 'cacapoum3' + url_params = { + 'model': mail.model, + 'id': mail.res_id, + } + print 'cacapoum4' + url = urljoin(base_url, "?#%s" % (urlencode(url_params))) + print 'cacapoum5' + text = _("""<p>Read this document <a href="%s">directly in OpenERP</a></p>""") % url + except: + print 'Failed !! Failled !!' + text = _("""<p>Access your messages through <a href="%s">our Customer Portal</a></p>""") % partner.signup_url + # partner not user + else: + text = _("""<p>Access your messages through <a href="%s">our Customer Portal</a></p>""") % partner.signup_url body = append_content_to_html(body, ("<div><p>%s</p></div>" % text), plaintext=False) return body
_______________________________________________ Mailing list: https://launchpad.net/~openerp-dev-gtk Post to : openerp-dev-gtk@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-dev-gtk More help : https://help.launchpad.net/ListHelp