From 501d791ea0d035a6dd016d9505940e29e98d729d Mon Sep 17 00:00:00 2001 From: "mga@tinyerp.com" <> Date: Wed, 23 Jul 2008 13:03:17 +0530 Subject: [PATCH 1/5] * add action for email, send email using the tools.email_send_attach method * ehance email_send_attach method for debug + ssl support bzr revid: mga@tinyerp.com-20080723073317-12l0v1pejz2fks9l --- bin/addons/base/ir/ir_actions.py | 11 +++++++++-- bin/tools/misc.py | 12 +++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index a4a7ae71d1c..bf6a960eac8 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -30,6 +30,7 @@ from osv import fields,osv import tools import time +from tools.config import config class actions(osv.osv): _name = 'ir.actions.actions' @@ -316,11 +317,17 @@ class actions_server(osv.osv): 'cr': cr, 'uid': uid } - print action.code exec action.code in localdict - print localdict.keys() if 'action' in localdict: return localdict['action'] + if action.state == 'email': + user = "%s@yahoo.co.in," % (config['smtp_user']) + subject = action.name + body = action.message + if tools.email_send_attach(user, action.address, subject, body) == True: + print 'email send successfully' + else: + print 'email sending failed' return False actions_server() diff --git a/bin/tools/misc.py b/bin/tools/misc.py index 4523c762c0a..345a62d625c 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -335,7 +335,7 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non #---------------------------------------------------------- # Emails #---------------------------------------------------------- -def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_bcc=None, on_error=False, reply_to=False, attach=None, tinycrm=False): +def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_bcc=None, on_error=False, reply_to=False, attach=None, tinycrm=False, ssl=False, debug=False): """Send an email.""" if not email_cc: email_cc=[] @@ -359,6 +359,7 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_ if reply_to: msg['Reply-To'] = reply_to msg['To'] = COMMASPACE.join(email_to) + print '************', msg['To'] if email_cc: msg['Cc'] = COMMASPACE.join(email_cc) if email_bcc: @@ -375,6 +376,15 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_ msg.attach(part) try: s = smtplib.SMTP() + + if debug: + s.debuglevel = 5 + + if ssl: + s.ehlo() + s.starttls() + s.ehlo() + s.connect(config['smtp_server']) if config['smtp_user'] or config['smtp_password']: s.login(config['smtp_user'], config['smtp_password']) From c4b8ea7041dd554baded534b35cfddf8ae5e19cb Mon Sep 17 00:00:00 2001 From: "mga@tinyerp.com" <> Date: Wed, 23 Jul 2008 13:46:45 +0530 Subject: [PATCH 2/5] change the message, use tiny logging system for the standar message change few things in to the email_send_attach method for the return type bzr revid: mga@tinyerp.com-20080723081645-icvyqapkvum0py4n --- bin/addons/base/ir/ir_actions.py | 6 ++++-- bin/tools/misc.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index bf6a960eac8..50168aac610 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -31,6 +31,7 @@ from osv import fields,osv import tools import time from tools.config import config +import netsvc class actions(osv.osv): _name = 'ir.actions.actions' @@ -307,6 +308,7 @@ class actions_server(osv.osv): # False : Finnished correctly # ACTION_ID : Action to launch def run(self, cr, uid, ids, context={}): + logger = netsvc.Logger() for action in self.browse(cr, uid, ids, context): if action.state=='python': localdict = { @@ -325,9 +327,9 @@ class actions_server(osv.osv): subject = action.name body = action.message if tools.email_send_attach(user, action.address, subject, body) == True: - print 'email send successfully' + logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (user)) else: - print 'email sending failed' + logger.notifyChannel('email', netsvc.LOG_ERROR, 'Failed to send email to : %s' % (user)) return False actions_server() diff --git a/bin/tools/misc.py b/bin/tools/misc.py index 345a62d625c..f534d0e84da 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -359,7 +359,6 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_ if reply_to: msg['Reply-To'] = reply_to msg['To'] = COMMASPACE.join(email_to) - print '************', msg['To'] if email_cc: msg['Cc'] = COMMASPACE.join(email_cc) if email_bcc: @@ -393,6 +392,8 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_ except Exception, e: import logging logging.getLogger().error(str(e)) + return False + return True #---------------------------------------------------------- From 692c4d97b31f49ba69057ca5b225f94a1f8f2afe Mon Sep 17 00:00:00 2001 From: "mga@tinyerp.com" <> Date: Wed, 23 Jul 2008 14:01:13 +0530 Subject: [PATCH 3/5] Add access for the res.request which is used for the internal system * users * procrument * production modules too default access for the read, write, create bzr revid: mga@tinyerp.com-20080723083113-e7xtv6pw0vkf9vkw --- bin/addons/base/base_security.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/addons/base/base_security.xml b/bin/addons/base/base_security.xml index ed4ede6649e..bf529a157d4 100644 --- a/bin/addons/base/base_security.xml +++ b/bin/addons/base/base_security.xml @@ -650,5 +650,13 @@ + + Internal Request + + + + + + \ No newline at end of file From 96ed63b84a78faf8fc62031059cd532b088a63bb Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 23 Jul 2008 13:30:21 +0200 Subject: [PATCH 4/5] bugfix: original constraint message is showed when there is no translations bzr revid: christophe@tinyerp.com-20080723113021-7jgz9j99imrcokxh --- bin/osv/orm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 789d2fa27f8..3fdaddfa92c 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -635,7 +635,7 @@ class orm_template(object): fun, msg, fields = constraint if not fun(self, cr, uid, ids): field_error += fields - field_err_str.append( trans._get_source(cr, uid, self._name, 'constraint', lng, source=msg) ) + field_err_str.append( trans._get_source(cr, uid, self._name, 'constraint', lng, source=msg) or msg ) if len(field_err_str): cr.rollback() raise except_orm('ValidateError', ('\n'.join(field_err_str), ','.join(field_error))) From 19d0053be2fd225b4140ebe66dcb264a13a8f20a Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 23 Jul 2008 13:46:00 +0200 Subject: [PATCH 5/5] export language: no crash when no modules selected bzr revid: christophe@tinyerp.com-20080723114600-1aqq8m974dbp8vda --- bin/tools/translate.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 123d673d238..3c0530c3aa9 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -240,6 +240,9 @@ def trans_generate(lang, modules, dbname=None): logger = netsvc.Logger() if not dbname: dbname=tools.config['db_name'] + if not modules: + modules = ['all'] + pool = pooler.get_pool(dbname) trans_obj = pool.get('ir.translation') model_data_obj = pool.get('ir.model.data')