return body and tools.ustr(body) or ''
def format_mail(self, obj, body):
- """ Foramat Mail
- @param self: The object pointer """
-
data = {
'object_id': obj.id,
'object_subject': hasattr(obj, 'name') and obj.name or False,
'object_description': hasattr(obj, 'description') and obj.description or False,
'object_user': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.name) or '/',
'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and \
- obj.user_id.address_id and obj.user_id.address_id.email) or '/',
- 'object_user_phone': hasattr(obj, 'user_id') and (obj.user_id and\
- obj.user_id.address_id and obj.user_id.address_id.phone) or '/',
+ obj.user_id.user_email) or '/',
+ 'object_user_phone': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and \
+ obj.partner_address_id.phone) or '/',
'partner': hasattr(obj, 'partner_id') and (obj.partner_id and obj.partner_id.name) or '/',
'partner_email': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and\
obj.partner_address_id.email) or '/',
if context is None:
context = {}
- email_message_obj = self.pool.get('email.message')
+ mail_message = self.pool.get('mail.message')
body = self.format_mail(obj, body)
if not emailfrom:
- if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and\
- obj.user_id.address_id.email:
- emailfrom = obj.user_id.address_id.email
+ if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.user_email:
+ emailfrom = obj.user_id.user_email
name = '[%d] %s' % (obj.id, tools.ustr(obj.name))
emailfrom = tools.ustr(emailfrom)
if not emailfrom:
raise osv.except_osv(_('Error!'),
_("No E-Mail ID Found for your Company address!"))
- return email_message_obj.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, openobject_id=str(obj.id))
+ return mail_message.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, res_id=obj.id)
def do_check(self, cr, uid, action, obj, context=None):
emails = []
if hasattr(obj, 'user_id') and action.act_mail_to_user:
- if obj.user_id and obj.user_id.address_id:
- emails.append(obj.user_id.address_id.email)
+ if obj.user_id:
+ emails.append(obj.user_id.user_email)
if action.act_mail_to_watchers:
emails += (action.act_email_cc or '').split(',')
class ir_cron(osv.osv):
_inherit = 'ir.cron'
+ _init_done = False
def _poolJobs(self, db_name, check=False):
- try:
- db = pooler.get_db(db_name)
- except:
- return False
- cr = db.cursor()
- try:
- next = datetime.now().strftime('%Y-%m-%d %H:00:00')
- # Putting nextcall always less than current time in order to call it every time
- cr.execute('UPDATE ir_cron set nextcall = \'%s\' where numbercall<>0 and active and model=\'base.action.rule\' ' % (next))
- finally:
- cr.commit()
- cr.close()
+ if not self._init_done:
+ self._init_done = True
+ try:
+ db = pooler.get_db(db_name)
+ except:
+ return False
+ cr = db.cursor()
+ try:
+ next = datetime.now().strftime('%Y-%m-%d %H:00:00')
+ # Putting nextcall always less than current time in order to call it every time
+ cr.execute('UPDATE ir_cron set nextcall = \'%s\' where numbercall<>0 and active and model=\'base.action.rule\' ' % (next))
+ finally:
+ cr.commit()
+ cr.close()
super(ir_cron, self)._poolJobs(db_name, check=check)