From 6bbab3d9b517376a1058b63fd4a42ed0b77ed762 Mon Sep 17 00:00:00 2001 From: sebastien beau Date: Mon, 6 Jun 2011 17:55:52 +0200 Subject: [PATCH] [IMP] improve and port to V6 --- .../{__terp__.py => __openerp__.py} | 2 +- scheduler_error_mailer/ir_cron.py | 38 +++++++++---------- scheduler_error_mailer/ir_cron.xml | 6 +-- 3 files changed, 23 insertions(+), 23 deletions(-) rename scheduler_error_mailer/{__terp__.py => __openerp__.py} (91%) diff --git a/scheduler_error_mailer/__terp__.py b/scheduler_error_mailer/__openerp__.py similarity index 91% rename from scheduler_error_mailer/__terp__.py rename to scheduler_error_mailer/__openerp__.py index f136674a1..aead8b9fd 100644 --- a/scheduler_error_mailer/__terp__.py +++ b/scheduler_error_mailer/__openerp__.py @@ -25,7 +25,7 @@ 'version': '0.1', 'category': 'Generic Modules/Others', 'license': 'AGPL-3', - 'description': """This module add the posibility to send a email when a scheduler raise an error""", + 'description': """This module dfkdsjfkdsjkfjksadd the posibility to send a email when a scheduler raise an error""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', 'depends': ['poweremail'], diff --git a/scheduler_error_mailer/ir_cron.py b/scheduler_error_mailer/ir_cron.py index b252536cc..dab5a8feb 100644 --- a/scheduler_error_mailer/ir_cron.py +++ b/scheduler_error_mailer/ir_cron.py @@ -27,29 +27,29 @@ class ir_cron(osv.osv, netsvc.Agent): _inherit = "ir.cron" _columns = { - 'email_TO' : fields.char('TO', size=256, help="If an error occure with this scheduler an email will be send"), + 'email_to' : fields.char('TO', size=256, help="If an error occure with this scheduler an email will be send"), 'message' : fields.text('Message', help="If an error occure with this scheduler this message will be send via email"), - 'send_email?' : fields.boolean('Active'), + 'send_email' : fields.boolean('Active'), 'email_account' : fields.many2one('poweremail.core_accounts', 'FROM') } - def _callback(self, cr, uid, model, func, args, job_id): - res = super(ir_cron, self)._callback(cr, uid, model, func, args, job_id) - if not res: - job = self.read(cr, uid, job_id, ['send_email?', 'message', 'email_TO', 'email_account', 'name']) - if job['send_email?']: - addresses = {'To' : job['email_TO']} - mail_obj = self.pool.get('poweremail.mailbox') - id = mail_obj.create(cr, uid, { - 'pem_to' : job['email_TO'], - 'pem_subject' : "OPENERP : error when excecuting scheduler " + job["name"], - 'pem_body_text' : job['message'], - 'pem_account_id' : job['email_account'][0], - 'mail_type' : 'text/plain', - 'folder' : 'outbox', - 'state' :'na', - }) - mail_obj.send_this_mail(cr, uid, [id]) + def _handle_callback_exception(self, cr, uid, model, func, args, job_id, job_exception): + super(ir_cron, self)._handle_callback_exception(cr, uid, model, func, args, job_id, job_exception) + job = self.read(cr, uid, job_id, ['send_email?', 'message', 'email_TO', 'email_account', 'name']) + #TODO USE POWEREMAIL TEMPLATE + if job['send_email?']: + addresses = {'To' : job['email_TO']} + mail_obj = self.pool.get('poweremail.mailbox') + id = mail_obj.create(cr, uid, { + 'pem_to' : job['email_TO'], + 'pem_subject' : "OPENERP : error when excecuting scheduler " + job["name"], + 'pem_body_text' : job['message'], + 'pem_account_id' : job['email_account'][0], + 'mail_type' : 'text/plain', + 'folder' : 'outbox', + 'state' :'na', + }) + mail_obj.send_this_mail(cr, uid, [id]) return res ir_cron() diff --git a/scheduler_error_mailer/ir_cron.xml b/scheduler_error_mailer/ir_cron.xml index 051f45023..33a6d3dfe 100644 --- a/scheduler_error_mailer/ir_cron.xml +++ b/scheduler_error_mailer/ir_cron.xml @@ -2,7 +2,7 @@ @@ -16,9 +16,9 @@ - + - +