[IMP] mail: mail.message now has mail_server_id from template_id.
bzr revid: tde@openerp.com-20130722131725-i30xd4b03nui3hyw
This commit is contained in:
parent
db0cd38559
commit
f1f2b2ba06
|
@ -22,6 +22,7 @@
|
||||||
from openerp import tools
|
from openerp import tools
|
||||||
from openerp.osv import osv, fields
|
from openerp.osv import osv, fields
|
||||||
|
|
||||||
|
|
||||||
def _reopen(self, res_id, model):
|
def _reopen(self, res_id, model):
|
||||||
return {'type': 'ir.actions.act_window',
|
return {'type': 'ir.actions.act_window',
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
|
@ -34,7 +35,8 @@ def _reopen(self, res_id, model):
|
||||||
'context': {
|
'context': {
|
||||||
'default_model': model,
|
'default_model': model,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class mail_compose_message(osv.TransientModel):
|
class mail_compose_message(osv.TransientModel):
|
||||||
_inherit = 'mail.compose.message'
|
_inherit = 'mail.compose.message'
|
||||||
|
@ -58,7 +60,7 @@ class mail_compose_message(osv.TransientModel):
|
||||||
context = {}
|
context = {}
|
||||||
wizard_context = dict(context)
|
wizard_context = dict(context)
|
||||||
for wizard in self.browse(cr, uid, ids, context=context):
|
for wizard in self.browse(cr, uid, ids, context=context):
|
||||||
if wizard.template_id and not wizard.template_id.user_signature:
|
if wizard.template_id:
|
||||||
wizard_context['mail_notify_user_signature'] = False # template user_signature is added when generating body_html
|
wizard_context['mail_notify_user_signature'] = False # template user_signature is added when generating body_html
|
||||||
if not wizard.attachment_ids or wizard.composition_mode == 'mass_mail' or not wizard.template_id:
|
if not wizard.attachment_ids or wizard.composition_mode == 'mass_mail' or not wizard.template_id:
|
||||||
continue
|
continue
|
||||||
|
@ -75,7 +77,7 @@ class mail_compose_message(osv.TransientModel):
|
||||||
""" - mass_mailing: we cannot render, so return the template values
|
""" - mass_mailing: we cannot render, so return the template values
|
||||||
- normal mode: return rendered values """
|
- normal mode: return rendered values """
|
||||||
if template_id and composition_mode == 'mass_mail':
|
if template_id and composition_mode == 'mass_mail':
|
||||||
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids']
|
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'mail_server_id']
|
||||||
template_values = self.pool.get('email.template').read(cr, uid, template_id, fields, context)
|
template_values = self.pool.get('email.template').read(cr, uid, template_id, fields, context)
|
||||||
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
|
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
|
||||||
elif template_id:
|
elif template_id:
|
||||||
|
@ -95,7 +97,7 @@ class mail_compose_message(osv.TransientModel):
|
||||||
}
|
}
|
||||||
values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context))
|
values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context))
|
||||||
else:
|
else:
|
||||||
values = self.default_get(cr, uid, ['subject', 'body', 'email_from', 'email_to', 'email_cc', 'partner_to', 'reply_to', 'attachment_ids'], context=context)
|
values = self.default_get(cr, uid, ['subject', 'body', 'email_from', 'email_to', 'email_cc', 'partner_to', 'reply_to', 'attachment_ids', 'mail_server_id'], context=context)
|
||||||
|
|
||||||
if values.get('body_html'):
|
if values.get('body_html'):
|
||||||
values['body'] = values.pop('body_html')
|
values['body'] = values.pop('body_html')
|
||||||
|
@ -150,7 +152,7 @@ class mail_compose_message(osv.TransientModel):
|
||||||
mail.compose.message, transform email_cc and email_to into partner_ids """
|
mail.compose.message, transform email_cc and email_to into partner_ids """
|
||||||
template_values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
|
template_values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
|
||||||
# filter template values
|
# filter template values
|
||||||
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'attachments']
|
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'attachments', 'mail_server_id']
|
||||||
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
|
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
|
||||||
values['body'] = values.pop('body_html', '')
|
values['body'] = values.pop('body_html', '')
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ class mail_notification(osv.Model):
|
||||||
return footer
|
return footer
|
||||||
|
|
||||||
def _notify(self, cr, uid, msg_id, partners_to_notify=None, context=None,
|
def _notify(self, cr, uid, msg_id, partners_to_notify=None, context=None,
|
||||||
force_send=False, user_signature=True):
|
force_send=False, user_signature=True):
|
||||||
""" Send by email the notification depending on the user preferences
|
""" Send by email the notification depending on the user preferences
|
||||||
|
|
||||||
:param list partners_to_notify: optional list of partner ids restricting
|
:param list partners_to_notify: optional list of partner ids restricting
|
||||||
|
|
|
@ -44,7 +44,6 @@ class mail_mail(osv.Model):
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'mail_message_id': fields.many2one('mail.message', 'Message', required=True, ondelete='cascade'),
|
'mail_message_id': fields.many2one('mail.message', 'Message', required=True, ondelete='cascade'),
|
||||||
'mail_server_id': fields.many2one('ir.mail_server', 'Outgoing mail server', readonly=1),
|
|
||||||
'state': fields.selection([
|
'state': fields.selection([
|
||||||
('outgoing', 'Outgoing'),
|
('outgoing', 'Outgoing'),
|
||||||
('sent', 'Sent'),
|
('sent', 'Sent'),
|
||||||
|
|
|
@ -191,6 +191,7 @@ class mail_message(osv.Model):
|
||||||
'vote_user_ids': fields.many2many('res.users', 'mail_vote',
|
'vote_user_ids': fields.many2many('res.users', 'mail_vote',
|
||||||
'message_id', 'user_id', string='Votes',
|
'message_id', 'user_id', string='Votes',
|
||||||
help='Users that voted for this message'),
|
help='Users that voted for this message'),
|
||||||
|
'mail_server_id': fields.many2one('ir.mail_server', 'Outgoing mail server', readonly=1),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _needaction_domain_get(self, cr, uid, context=None):
|
def _needaction_domain_get(self, cr, uid, context=None):
|
||||||
|
@ -780,8 +781,8 @@ class mail_message(osv.Model):
|
||||||
values['message_id'] = tools.generate_tracking_message_id('private')
|
values['message_id'] = tools.generate_tracking_message_id('private')
|
||||||
newid = super(mail_message, self).create(cr, uid, values, context)
|
newid = super(mail_message, self).create(cr, uid, values, context)
|
||||||
self._notify(cr, uid, newid, context=context,
|
self._notify(cr, uid, newid, context=context,
|
||||||
force_send=context.get('mail_notify_force_send', True),
|
force_send=context.get('mail_notify_force_send', True),
|
||||||
user_signature=context.get('mail_notify_user_signature', True))
|
user_signature=context.get('mail_notify_user_signature', True))
|
||||||
# TDE FIXME: handle default_starred. Why not setting an inv on starred ?
|
# TDE FIXME: handle default_starred. Why not setting an inv on starred ?
|
||||||
# Because starred will call set_message_starred, that looks for notifications.
|
# Because starred will call set_message_starred, that looks for notifications.
|
||||||
# When creating a new mail_message, it will create a notification to a message
|
# When creating a new mail_message, it will create a notification to a message
|
||||||
|
|
|
@ -130,6 +130,7 @@ class mail_compose_message(osv.TransientModel):
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'composition_mode': 'comment',
|
'composition_mode': 'comment',
|
||||||
'body': lambda self, cr, uid, ctx={}: '',
|
'body': lambda self, cr, uid, ctx={}: '',
|
||||||
|
'subject': lambda self, cr, uid, ctx={}: False,
|
||||||
'partner_ids': lambda self, cr, uid, ctx={}: [],
|
'partner_ids': lambda self, cr, uid, ctx={}: [],
|
||||||
'post': lambda self, cr, uid, ctx={}: True,
|
'post': lambda self, cr, uid, ctx={}: True,
|
||||||
'same_thread': lambda self, cr, uid, ctx={}: True,
|
'same_thread': lambda self, cr, uid, ctx={}: True,
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<field name="model" invisible="1"/>
|
<field name="model" invisible="1"/>
|
||||||
<field name="res_id" invisible="1"/>
|
<field name="res_id" invisible="1"/>
|
||||||
<field name="parent_id" invisible="1"/>
|
<field name="parent_id" invisible="1"/>
|
||||||
|
<field name="mail_server_id" invisible="1"/>
|
||||||
<!-- visible wizard -->
|
<!-- visible wizard -->
|
||||||
<field name="email_from"
|
<field name="email_from"
|
||||||
attrs="{'invisible':[('composition_mode', '!=', 'mass_mail')]}"/>
|
attrs="{'invisible':[('composition_mode', '!=', 'mass_mail')]}"/>
|
||||||
|
|
Loading…
Reference in New Issue