[FIX] email_template, mail: added constraint and fix return type for mako template in email_template
bzr revid: rha@tinyerp.com-20110414113401-dwhhu7srusqh4yfj
This commit is contained in:
parent
482ca7ddd3
commit
c61bf2dcf4
|
@ -47,7 +47,9 @@ def get_value(cr, uid, message=None, model=None, record_id=False, context=None):
|
|||
}
|
||||
templ = MakoTemplate(message, input_encoding='utf-8')
|
||||
reply = MakoTemplate(message).render_unicode(object=record, peobject=record, env=env, format_exceptions=True)
|
||||
return reply or False
|
||||
if reply == 'False':
|
||||
reply = ''
|
||||
return reply
|
||||
except Exception:
|
||||
logging.exception("can't render %r", message)
|
||||
return u""
|
||||
|
|
|
@ -94,6 +94,7 @@ class email_message_common(osv.osv_memory):
|
|||
_rec_name = 'subject'
|
||||
|
||||
_sql_constraints = []
|
||||
|
||||
email_message_common()
|
||||
|
||||
class email_message(osv.osv):
|
||||
|
@ -105,6 +106,19 @@ class email_message(osv.osv):
|
|||
_description = 'Email Message'
|
||||
_order = 'date desc'
|
||||
|
||||
def _check_email_recipients(self, cr, uid, ids, context=None):
|
||||
'''
|
||||
checks email_to, email_cc, email_bcc
|
||||
'''
|
||||
for message in self.browse(cr, uid, ids, context=context):
|
||||
if not (message.email_to or message.email_cc or message.email_bcc):
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_email_recipients, 'No recipients were specified. Please enter a recipient!', ['email_to', 'email_cc', 'email_bcc']),
|
||||
]
|
||||
|
||||
def open_document(self, cr, uid, ids, context=None):
|
||||
""" To Open Document
|
||||
@param self: The object pointer.
|
||||
|
|
Loading…
Reference in New Issue