|
@ -1,9 +1,11 @@ |
|
|
import openerp |
|
|
|
|
|
from openerp import api, models, fields, SUPERUSER_ID, tools |
|
|
|
|
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
from openerp import SUPERUSER_ID |
|
|
|
|
|
from openerp import models |
|
|
|
|
|
from openerp import tools |
|
|
from openerp.osv import fields as old_fields |
|
|
from openerp.osv import fields as old_fields |
|
|
from openerp.tools import html2plaintext |
|
|
|
|
|
from openerp.tools.translate import _ |
|
|
from openerp.tools.translate import _ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class res_partner(models.Model): |
|
|
class res_partner(models.Model): |
|
|
_inherit = 'res.partner' |
|
|
_inherit = 'res.partner' |
|
|
_columns = { |
|
|
_columns = { |
|
@ -13,12 +15,13 @@ class res_partner(models.Model): |
|
|
('im_xor_email', 'IM (if online) + email (if offline)'), |
|
|
('im_xor_email', 'IM (if online) + email (if offline)'), |
|
|
('im_and_email', 'IM (if online) + email'), |
|
|
('im_and_email', 'IM (if online) + email'), |
|
|
('always', 'Only emails'), |
|
|
('always', 'Only emails'), |
|
|
], 'Receive Inbox Notifications by Email, IM', required=True, |
|
|
|
|
|
|
|
|
], 'Receive Inbox Notifications by Email, IM', required=True, |
|
|
oldname='notification_email_send', |
|
|
oldname='notification_email_send', |
|
|
help="Policy to receive emails, IM for new messages pushed to your personal Inbox. IM can be used only for partners with odoo user account" |
|
|
help="Policy to receive emails, IM for new messages pushed to your personal Inbox. IM can be used only for partners with odoo user account" |
|
|
), |
|
|
|
|
|
|
|
|
), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class mail_notification(models.Model): |
|
|
class mail_notification(models.Model): |
|
|
_inherit = 'mail.notification' |
|
|
_inherit = 'mail.notification' |
|
|
|
|
|
|
|
@ -51,7 +54,7 @@ class mail_notification(models.Model): |
|
|
continue |
|
|
continue |
|
|
send_email = False |
|
|
send_email = False |
|
|
for user in partner.user_ids: |
|
|
for user in partner.user_ids: |
|
|
if user.im_status=='offline': |
|
|
|
|
|
|
|
|
if user.im_status == 'offline': |
|
|
if n != 'im': |
|
|
if n != 'im': |
|
|
send_email = True |
|
|
send_email = True |
|
|
else: |
|
|
else: |
|
@ -79,26 +82,25 @@ class mail_notification(models.Model): |
|
|
) |
|
|
) |
|
|
author = message.author_id and message.author_id.name_get() |
|
|
author = message.author_id and message.author_id.name_get() |
|
|
author = author and author[0][1] or message.email_from |
|
|
author = author and author[0][1] or message.email_from |
|
|
#body = html2plaintext(message.body)[:100] or '' |
|
|
|
|
|
|
|
|
# body = html2plaintext(message.body)[:100] or '' |
|
|
mtype = {'email': _('Email'), |
|
|
mtype = {'email': _('Email'), |
|
|
'comment': _('Comment'), |
|
|
'comment': _('Comment'), |
|
|
'notification': _('System notification'), |
|
|
'notification': _('System notification'), |
|
|
}.get(message.type, '') |
|
|
|
|
|
|
|
|
}.get(message.type, '') |
|
|
|
|
|
|
|
|
about = message.subject or message.record_name or 'UNDEFINED' |
|
|
about = message.subject or message.record_name or 'UNDEFINED' |
|
|
about = '[ABOUT] %s' % about |
|
|
about = '[ABOUT] %s' % about |
|
|
if url: |
|
|
if url: |
|
|
about = '<a href="%s">%s</a>' % (url, about) |
|
|
|
|
|
|
|
|
about = '<a href="%s">%s</a>' % (url, about) |
|
|
im_text = [ |
|
|
im_text = [ |
|
|
'_____________________', |
|
|
'_____________________', |
|
|
'<a href="%s">_____[open_inbox]_____</a>' % inbox_url, |
|
|
'<a href="%s">_____[open_inbox]_____</a>' % inbox_url, |
|
|
'%s [FROM] %s' % (message.type, author), |
|
|
'%s [FROM] %s' % (message.type, author), |
|
|
about, |
|
|
about, |
|
|
] |
|
|
] |
|
|
#im_text = im_text + body.split('\n') |
|
|
|
|
|
|
|
|
# im_text = im_text + body.split('\n') |
|
|
return im_text |
|
|
return im_text |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _notify_email(self, cr, uid, ids, message_id, force_send=False, user_signature=True, context=None): |
|
|
def _notify_email(self, cr, uid, ids, message_id, force_send=False, user_signature=True, context=None): |
|
|
# based on addons/mail/mail_followers.py::_notify_email |
|
|
# based on addons/mail/mail_followers.py::_notify_email |
|
|
message = self.pool['mail.message'].browse(cr, SUPERUSER_ID, message_id, context=context) |
|
|
message = self.pool['mail.message'].browse(cr, SUPERUSER_ID, message_id, context=context) |
|
@ -128,7 +130,6 @@ class mail_notification(models.Model): |
|
|
|
|
|
|
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _do_notify_email(self, cr, uid, email_pids, message, force_send=False, user_signature=True, context=None): |
|
|
def _do_notify_email(self, cr, uid, email_pids, message, force_send=False, user_signature=True, context=None): |
|
|
|
|
|
|
|
|
# compute email body (signature, company data) |
|
|
# compute email body (signature, company data) |
|
|