@@ -23,13 +23,8 @@
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
import base64
|
||||
import random
|
||||
import netsvc
|
||||
import logging
|
||||
import re
|
||||
from tools.translate import _
|
||||
import tools
|
||||
import pooler
|
||||
|
||||
class email_template(osv.osv):
|
||||
"Templates for sending Email"
|
||||
@@ -45,7 +40,7 @@ class email_template(osv.osv):
|
||||
"Return Template Object"
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
|
||||
if not template_id:
|
||||
return False
|
||||
|
||||
@@ -355,7 +350,7 @@ class email_template(osv.osv):
|
||||
report_xml_pool = self.pool.get('ir.actions.report.xml')
|
||||
template = self.get_email_template(cr, uid, template_id, record_id, context)
|
||||
def _get_template_value(field):
|
||||
if context.get('mass_mail',False): # Mass Mail: Gets original template values for multiple email change
|
||||
if context.get('mass_mail', False): # Mass Mail: Gets original template values for multiple email change
|
||||
return getattr(template, field)
|
||||
else:
|
||||
return self.get_template_value(cr, uid, getattr(template, field), template.model, record_id, context=context)
|
||||
@@ -404,7 +399,7 @@ class email_template(osv.osv):
|
||||
# Add document attachments
|
||||
for attach in template.attachment_ids:
|
||||
#attach = attahcment_obj.browse(cr, uid, attachment_id, context)
|
||||
attachment[attach.datas_fname] = attach.datas
|
||||
attachment[attach.datas_fname] = base64.decodestring(attach.datas)
|
||||
values['attachment'] = attachment
|
||||
return values
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#
|
||||
##############################################################################
|
||||
import tools
|
||||
from tools.translate import _
|
||||
import pooler
|
||||
import logging
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
import tools
|
||||
from tools.translate import _
|
||||
import binascii
|
||||
|
||||
@@ -42,10 +41,10 @@ class email_compose_message(osv.osv_memory):
|
||||
message_pool = self.pool.get('email.message')
|
||||
message_data = message_pool.browse(cr, uid, int(context.get('message_id')), context)
|
||||
model = message_data.model
|
||||
elif context.get('active_model',False):
|
||||
model = context.get('active_model')
|
||||
elif context.get('active_model', False):
|
||||
model = context.get('active_model')
|
||||
if model:
|
||||
record_ids = email_temp_pool.search(cr, uid, [('model','=',model)])
|
||||
record_ids = email_temp_pool.search(cr, uid, [('model', '=', model)])
|
||||
return email_temp_pool.name_get(cr, uid, record_ids, context) + [(False,'')]
|
||||
return []
|
||||
|
||||
@@ -61,22 +60,24 @@ class email_compose_message(osv.osv_memory):
|
||||
if context is None:
|
||||
context = {}
|
||||
att_ids = []
|
||||
res_id = context.get('active_id', False)
|
||||
values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
|
||||
if values['attachment']:
|
||||
attachment = values['attachment']
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
for fname, fcontent in attachment.items():
|
||||
data_attach = {
|
||||
'name': fname,
|
||||
'datas': binascii.b2a_base64(str(fcontent)),
|
||||
'datas_fname': fname,
|
||||
'description': _('Mail attachment'),
|
||||
'res_model' : self._name,
|
||||
'res_id' : ids and ids[0] or False
|
||||
}
|
||||
att_ids.append(attachment_obj.create(cr, uid, data_attach))
|
||||
values['attachment_ids'] = att_ids
|
||||
values = {}
|
||||
if template_id:
|
||||
res_id = context.get('active_id', False)
|
||||
values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
|
||||
if values['attachment']:
|
||||
attachment = values['attachment']
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
for fname, fcontent in attachment.items():
|
||||
data_attach = {
|
||||
'name': fname,
|
||||
'datas': binascii.b2a_base64(str(fcontent)),
|
||||
'datas_fname': fname,
|
||||
'description': _('Mail attachment'),
|
||||
'res_model' : self._name,
|
||||
'res_id' : ids and ids[0] or False
|
||||
}
|
||||
att_ids.append(attachment_obj.create(cr, uid, data_attach))
|
||||
values['attachment_ids'] = att_ids
|
||||
return {'value': values}
|
||||
|
||||
def save_as_template(self, cr, uid, ids, context=None):
|
||||
@@ -89,7 +90,7 @@ class email_compose_message(osv.osv_memory):
|
||||
model_pool = self.pool.get('ir.model')
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
model = context.get('active_model', record.model or False)
|
||||
model = model_pool.search(cr, uid, [('model','=', model)])[0]
|
||||
model = model_pool.search(cr, uid, [('model', '=', model)])[0]
|
||||
model_name = model_pool.browse(cr, uid, model, context=context).name
|
||||
values = {
|
||||
'name': model_name,
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
import tools
|
||||
|
||||
|
||||
class email_template_preview(osv.osv_memory):
|
||||
_inherit = "email.template"
|
||||
@@ -38,11 +35,10 @@ class email_template_preview(osv.osv_memory):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
template_id = context.get('active_id', False)
|
||||
template_id = context.get('template_id', False)
|
||||
if not template_id:
|
||||
return []
|
||||
template_pool = self.pool.get('email.template')
|
||||
model_pool = self.pool.get('ir.model')
|
||||
template = template_pool.browse(cr, uid, int(template_id), context=context)
|
||||
template_object = template.model_id
|
||||
model = self.pool.get(template_object.model)
|
||||
@@ -61,7 +57,7 @@ class email_template_preview(osv.osv_memory):
|
||||
result = super(email_template_preview, self).default_get(cr, uid, fields, context=context)
|
||||
|
||||
template_pool = self.pool.get('email.template')
|
||||
template_id = context.get('active_id',False)
|
||||
template_id = context.get('active_id', False)
|
||||
if 'res_id' in fields:
|
||||
records = self._get_records(cr, uid, context=context)
|
||||
result['res_id'] = records and records[0][0] or False # select first record as a Default
|
||||
@@ -72,8 +68,7 @@ class email_template_preview(osv.osv_memory):
|
||||
_columns = {
|
||||
'res_id':fields.selection(_get_records, 'Referred Document'),
|
||||
}
|
||||
_defaults = {
|
||||
}
|
||||
|
||||
def on_change_ref(self, cr, uid, ids, res_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
@@ -162,7 +162,7 @@ class email_message(osv.osv):
|
||||
"""
|
||||
action_data = False
|
||||
action_pool = self.pool.get('ir.actions.act_window')
|
||||
message_pool = self.browse(cr ,uid, ids, context=context)[0]
|
||||
message_pool = self.browse(cr, uid, ids, context=context)[0]
|
||||
att_ids = [x.id for x in message_pool.attachment_ids]
|
||||
action_ids = action_pool.search(cr, uid, [('res_model', '=', 'ir.attachment')])
|
||||
if action_ids:
|
||||
@@ -309,8 +309,8 @@ class email_message(osv.osv):
|
||||
text = decode_header(text.replace('\r', ''))
|
||||
return ''.join([tools.ustr(x[0], x[1]) for x in text])
|
||||
|
||||
def to_email(self,text):
|
||||
return re.findall(r'([^ ,<@]+@[^> ,]+)',text)
|
||||
def to_email(self, text):
|
||||
return re.findall(r'([^ ,<@]+@[^> ,]+)', text)
|
||||
|
||||
def parse_message(self, message):
|
||||
"""Return Dictionary Object after parse EML Message String
|
||||
@@ -390,7 +390,6 @@ class email_message(osv.osv):
|
||||
msg['body'] = tools.ustr(body, encoding)
|
||||
|
||||
attachments = {}
|
||||
has_plain_text = False
|
||||
if msg_txt.is_multipart() or 'multipart/alternative' in msg.get('content-type', ''):
|
||||
body = ""
|
||||
if 'multipart/alternative' in msg.get('content-type', ''):
|
||||
|
||||
@@ -26,7 +26,6 @@ import binascii
|
||||
import email
|
||||
|
||||
from email.utils import parsedate
|
||||
import base64
|
||||
|
||||
from tools.translate import _
|
||||
import logging
|
||||
@@ -77,7 +76,7 @@ class email_thread(osv.osv):
|
||||
model_pool = self.pool.get(model)
|
||||
fields = model_pool.fields_get(cr, uid, context=context)
|
||||
data = model_pool.default_get(cr, uid, fields, context=context)
|
||||
if 'name' in fields and not data.get('name',False):
|
||||
if 'name' in fields and not data.get('name', False):
|
||||
data['name'] = msg.get('from','')
|
||||
res_id = model_pool.create(cr, uid, data, context=context)
|
||||
|
||||
@@ -137,7 +136,7 @@ class email_thread(osv.osv):
|
||||
if isinstance(ids, (str, int, long)):
|
||||
ids = [long(ids)]
|
||||
for thread in self.browse(cr, uid, ids, context=context):
|
||||
l=[]
|
||||
l = []
|
||||
for message in thread.message_ids:
|
||||
l.append((message.user_id and message.user_id.email) or '')
|
||||
l.append(message.email_from or '')
|
||||
|
||||
@@ -131,7 +131,7 @@ class email_compose_message(osv.osv_memory):
|
||||
message_id = False
|
||||
|
||||
# Reply Email
|
||||
if context.get('mail',False) == 'reply' and mail.message_id:
|
||||
if context.get('mail') == 'reply' and mail.message_id:
|
||||
references = mail.references and mail.references + "," + mail.message_id or mail.message_id
|
||||
else:
|
||||
message_id = mail.message_id
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<group col="4" colspan="4">
|
||||
<label string="" colspan="1"/>
|
||||
<button icon="gtk-close" special="cancel" string="Close"/>
|
||||
<button icon="gtk-ok" name="send_mail" string="Send now" type="object"/>
|
||||
<button icon="gtk-ok" name="send_mail" string="Send" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user