email_template: code optimization, removed unused imports and useability fix
bzr revid: rha@tinyerp.com-20110511110423-ojb059dpf1m39ib5
This commit is contained in:
parent
5c0308f078
commit
89ee28b7d1
|
@ -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"
|
||||
|
@ -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)
|
||||
|
|
|
@ -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 []
|
||||
|
||||
|
@ -91,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"
|
||||
|
@ -42,7 +39,6 @@ class email_template_preview(osv.osv_memory):
|
|||
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 = {}
|
||||
|
|
Loading…
Reference in New Issue