From 910b26f28cdc6655f8a377090679a56882c7e87d Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 14:17:50 +0100 Subject: [PATCH 001/102] Get the scheduler to actually run rules with time delays. bzr revid: daniel.watkins@credativ.co.uk-20100909131750-ntafsguyput7r4xw --- addons/base_action_rule/base_action_rule.py | 81 +++++++++++---------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index ff6321e599f..16a628d9529 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -113,6 +113,7 @@ the rule to mark CC(mail to any other person defined in actions)."), 'filter_id':fields.many2one('ir.filters', 'Filter', required=False), 'act_email_from' : fields.char('Email From', size=64, required=False, help="Use a python expression to specify the right field on which one than we will use for the 'From' field of the header"), + 'last_run': fields.datetime('Last Run', readonly=1), } _defaults = { @@ -204,8 +205,48 @@ the rule to mark CC(mail to any other person defined in actions)."), """ rule_pool = self.pool.get('base.action.rule') rule_ids = rule_pool.search(cr, uid, [], context=context) - return self._register_hook(cr, uid, rule_ids, context=context) - + self._register_hook(cr, uid, rule_ids, context=context) + + rules = self.browse(cr, uid, rule_ids, context=context) + for rule in rules: + print "RULE: %s" % (rule,) + print " %s" % (rule.last_run,) + model = rule.model_id.model + model_pool = self.pool.get(model) + last_run = False + if rule.last_run: + last_run = datetime.strptime(rule.last_run[:19], '%Y-%m-%d %H:%M:%S') + now = datetime.now() + for obj_id in model_pool.search(cr, uid, [], context=context): + print " OBJ: %s" % (obj_id,) + obj = model_pool.browse(cr, uid, obj_id, context=context) + # Calculate when the action should next occur for this object + base = False + if rule.trg_date_type=='create' and hasattr(obj, 'create_date'): + base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') + elif rule.trg_date_type=='action_last' and hasattr(obj, 'create_date'): + if hasattr(obj, 'date_action_last') and obj.date_action_last: + base = datetime.strptime(obj.date_action_last, '%Y-%m-%d %H:%M:%S') + else: + base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') + elif rule.trg_date_type=='deadline' and hasattr(obj, 'date_deadline') \ + and obj.date_deadline: + base = datetime.strptime(obj.date_deadline, '%Y-%m-%d %H:%M:%S') + elif rule.trg_date_type=='date' and hasattr(obj, 'date') and obj.date: + base = datetime.strptime(obj.date, '%Y-%m-%d %H:%M:%S') + if base: + fnct = { + 'minutes': lambda interval: timedelta(minutes=interval), + 'day': lambda interval: timedelta(days=interval), + 'hour': lambda interval: timedelta(hours=interval), + 'month': lambda interval: timedelta(months=interval), + } + d = base + fnct[rule.trg_date_range_type](rule.trg_date_range) + print " D: %s" % (d,) + if (not last_run or (last_run <= d < now)): + print " RUNNING" + self._action(cr, uid, [rule.id], [obj], context=context) + rule_pool.write(cr, uid, [rule.id], {'last_run': now}, context=context) def format_body(self, body): """ Foramat Action rule's body @@ -377,7 +418,6 @@ the rule to mark CC(mail to any other person defined in actions)."), if context is None: context = {} - context.update({'action': True}) if not scrit: scrit = [] @@ -389,41 +429,6 @@ the rule to mark CC(mail to any other person defined in actions)."), if not ok: continue - base = False - if action.trg_date_type=='create' and hasattr(obj, 'create_date'): - base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') - elif action.trg_date_type=='action_last' and hasattr(obj, 'create_date'): - if hasattr(obj, 'date_action_last') and obj.date_action_last: - base = datetime.strptime(obj.date_action_last, '%Y-%m-%d %H:%M:%S') - else: - base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') - elif action.trg_date_type=='deadline' and hasattr(obj, 'date_deadline') \ - and obj.date_deadline: - base = datetime.strptime(obj.date_deadline, '%Y-%m-%d %H:%M:%S') - elif action.trg_date_type=='date' and hasattr(obj, 'date') and obj.date: - base = datetime.strptime(obj.date, '%Y-%m-%d %H:%M:%S') - if base: - fnct = { - 'minutes': lambda interval: timedelta(minutes=interval), - 'day': lambda interval: timedelta(days=interval), - 'hour': lambda interval: timedelta(hours=interval), - 'month': lambda interval: timedelta(months=interval), - } - d = base + fnct[action.trg_date_range_type](action.trg_date_range) - dt = d.strftime('%Y-%m-%d %H:%M:%S') - ok = False - if hasattr(obj, 'date_action_last') and hasattr(obj, 'date_action_next'): - ok = (dt <= time.strftime('%Y-%m-%d %H:%M:%S')) and \ - ((not obj.date_action_next) or \ - (dt >= obj.date_action_next and \ - obj.date_action_last < obj.date_action_next)) - if not ok: - if not obj.date_action_next or dt < obj.date_action_next: - obj.date_action_next = dt - model_obj.write(cr, uid, [obj.id], {'date_action_next': dt}, context) - else: - ok = action.trg_date_type == 'none' - if ok: self.do_action(cr, uid, action, model_obj, obj, context) break From 42ca50081352be6ecc44b3cc746553dbbda5c0a0 Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 14:26:26 +0100 Subject: [PATCH 002/102] SQL case fix. bzr revid: daniel.watkins@credativ.co.uk-20100909132626-wl8k91c4ae19ounv --- addons/base_action_rule/base_action_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 16a628d9529..75b3273dcab 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -144,7 +144,7 @@ the rule to mark CC(mail to any other person defined in actions)."), # Searching for action rules cr.execute("SELECT model.model, rule.id FROM base_action_rule rule \ LEFT JOIN ir_model model on (model.id = rule.model_id) \ - where active") + WHERE active") res = cr.fetchall() # Check if any rule matching with current object for obj_name, rule_id in res: From 7c33b854ceafd9bbe4f5053ae85fab5767879d34 Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 14:26:50 +0100 Subject: [PATCH 003/102] Comment change. bzr revid: daniel.watkins@credativ.co.uk-20100909132650-k4i750ub6y77rx8w --- addons/base_action_rule/base_action_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 75b3273dcab..fbb28c6fcc1 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -220,7 +220,7 @@ the rule to mark CC(mail to any other person defined in actions)."), for obj_id in model_pool.search(cr, uid, [], context=context): print " OBJ: %s" % (obj_id,) obj = model_pool.browse(cr, uid, obj_id, context=context) - # Calculate when the action should next occur for this object + # Calculate when this action should next occur for this object base = False if rule.trg_date_type=='create' and hasattr(obj, 'create_date'): base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') From e5465c80c81d75c5b2f1731546fbeeb29e7b79f0 Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 14:27:21 +0100 Subject: [PATCH 004/102] Don't run rules with time conditions from the create/write methods of models. bzr revid: daniel.watkins@credativ.co.uk-20100909132721-wlnqp4uzwf3s7gjb --- addons/base_action_rule/base_action_rule.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index fbb28c6fcc1..28cafade079 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -152,7 +152,10 @@ the rule to mark CC(mail to any other person defined in actions)."), continue else: obj = self.pool.get(obj_name) - self._action(cr, uid, [rule_id], obj.browse(cr, uid, ids, context=context), context=context) + # If the rule doesn't involve a time condition, run it immediately + # Otherwise we let the scheduler run the action + if self.browse(cr, uid, rule_id, context=context).trg_date_type == 'none': + self._action(cr, uid, [rule_id], obj.browse(cr, uid, ids, context=context), context=context) return True def _create(self, old_create, model, context=None): From 6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 14:50:42 +0100 Subject: [PATCH 005/102] Remove debugging statements. bzr revid: daniel.watkins@credativ.co.uk-20100909135042-0qvo42y2l9jfq70w --- addons/base_action_rule/base_action_rule.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 28cafade079..3038b43136a 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -212,8 +212,6 @@ the rule to mark CC(mail to any other person defined in actions)."), rules = self.browse(cr, uid, rule_ids, context=context) for rule in rules: - print "RULE: %s" % (rule,) - print " %s" % (rule.last_run,) model = rule.model_id.model model_pool = self.pool.get(model) last_run = False @@ -221,7 +219,6 @@ the rule to mark CC(mail to any other person defined in actions)."), last_run = datetime.strptime(rule.last_run[:19], '%Y-%m-%d %H:%M:%S') now = datetime.now() for obj_id in model_pool.search(cr, uid, [], context=context): - print " OBJ: %s" % (obj_id,) obj = model_pool.browse(cr, uid, obj_id, context=context) # Calculate when this action should next occur for this object base = False @@ -245,9 +242,7 @@ the rule to mark CC(mail to any other person defined in actions)."), 'month': lambda interval: timedelta(months=interval), } d = base + fnct[rule.trg_date_range_type](rule.trg_date_range) - print " D: %s" % (d,) if (not last_run or (last_run <= d < now)): - print " RUNNING" self._action(cr, uid, [rule.id], [obj], context=context) rule_pool.write(cr, uid, [rule.id], {'last_run': now}, context=context) From 9b37ccf4e29c54271d767140b80bdc75a67815c9 Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 15:13:28 +0100 Subject: [PATCH 006/102] Extract strptime calls to make code look clearer. bzr revid: daniel.watkins@credativ.co.uk-20100909141328-3qz1ome23ani3yrm --- addons/base_action_rule/base_action_rule.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 3038b43136a..73fd96f93c9 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -29,6 +29,11 @@ import re import time import tools + +def get_datetime(date_field): + return datetime.strptime(date_field[:19], '%Y-%m-%d %H:%M:%S') + + class base_action_rule(osv.osv): """ Base Action Rules """ @@ -216,24 +221,24 @@ the rule to mark CC(mail to any other person defined in actions)."), model_pool = self.pool.get(model) last_run = False if rule.last_run: - last_run = datetime.strptime(rule.last_run[:19], '%Y-%m-%d %H:%M:%S') + last_run = get_datetime(rule.last_run) now = datetime.now() for obj_id in model_pool.search(cr, uid, [], context=context): obj = model_pool.browse(cr, uid, obj_id, context=context) # Calculate when this action should next occur for this object base = False if rule.trg_date_type=='create' and hasattr(obj, 'create_date'): - base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') + base = get_datetime(obj.create_date) elif rule.trg_date_type=='action_last' and hasattr(obj, 'create_date'): if hasattr(obj, 'date_action_last') and obj.date_action_last: - base = datetime.strptime(obj.date_action_last, '%Y-%m-%d %H:%M:%S') + base = get_datetime(obj.date_action_last) else: - base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') + base = get_datetime(obj.create_date) elif rule.trg_date_type=='deadline' and hasattr(obj, 'date_deadline') \ and obj.date_deadline: - base = datetime.strptime(obj.date_deadline, '%Y-%m-%d %H:%M:%S') + base = get_datetime(obj.date_deadline) elif rule.trg_date_type=='date' and hasattr(obj, 'date') and obj.date: - base = datetime.strptime(obj.date, '%Y-%m-%d %H:%M:%S') + base = get_datetime(obj.date) if base: fnct = { 'minutes': lambda interval: timedelta(minutes=interval), From a298287a8cfdc81aac0d4d9b15724720a450150a Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 15:25:49 +0100 Subject: [PATCH 007/102] Even better removal of get_datetime stuff. bzr revid: daniel.watkins@credativ.co.uk-20100909142549-zl1yt8s7swcibno5 --- addons/base_action_rule/base_action_rule.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 73fd96f93c9..6d62985d022 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -228,17 +228,17 @@ the rule to mark CC(mail to any other person defined in actions)."), # Calculate when this action should next occur for this object base = False if rule.trg_date_type=='create' and hasattr(obj, 'create_date'): - base = get_datetime(obj.create_date) + base = obj.create_date elif rule.trg_date_type=='action_last' and hasattr(obj, 'create_date'): if hasattr(obj, 'date_action_last') and obj.date_action_last: - base = get_datetime(obj.date_action_last) + base = obj.date_action_last else: - base = get_datetime(obj.create_date) + base = obj.create_date elif rule.trg_date_type=='deadline' and hasattr(obj, 'date_deadline') \ and obj.date_deadline: - base = get_datetime(obj.date_deadline) + base = obj.date_deadline elif rule.trg_date_type=='date' and hasattr(obj, 'date') and obj.date: - base = get_datetime(obj.date) + base = obj.date if base: fnct = { 'minutes': lambda interval: timedelta(minutes=interval), @@ -246,6 +246,7 @@ the rule to mark CC(mail to any other person defined in actions)."), 'hour': lambda interval: timedelta(hours=interval), 'month': lambda interval: timedelta(months=interval), } + base = get_datetime(base) d = base + fnct[rule.trg_date_range_type](rule.trg_date_range) if (not last_run or (last_run <= d < now)): self._action(cr, uid, [rule.id], [obj], context=context) From 350887d5ab71e706932c8eb82360582cb0616a70 Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 15:27:08 +0100 Subject: [PATCH 008/102] Wrap long lines and remove trailing whitespace. bzr revid: daniel.watkins@credativ.co.uk-20100909142708-j16gpfvsxrh6qwno --- addons/base_action_rule/base_action_rule.py | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 6d62985d022..0e564915c7c 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -229,28 +229,33 @@ the rule to mark CC(mail to any other person defined in actions)."), base = False if rule.trg_date_type=='create' and hasattr(obj, 'create_date'): base = obj.create_date - elif rule.trg_date_type=='action_last' and hasattr(obj, 'create_date'): + elif (rule.trg_date_type=='action_last' + and hasattr(obj, 'create_date')): if hasattr(obj, 'date_action_last') and obj.date_action_last: base = obj.date_action_last else: base = obj.create_date - elif rule.trg_date_type=='deadline' and hasattr(obj, 'date_deadline') \ - and obj.date_deadline: + elif (rule.trg_date_type=='deadline' + and hasattr(obj, 'date_deadline') + and obj.date_deadline): base = obj.date_deadline - elif rule.trg_date_type=='date' and hasattr(obj, 'date') and obj.date: + elif (rule.trg_date_type=='date' + and hasattr(obj, 'date') + and obj.date): base = obj.date if base: fnct = { - 'minutes': lambda interval: timedelta(minutes=interval), - 'day': lambda interval: timedelta(days=interval), - 'hour': lambda interval: timedelta(hours=interval), - 'month': lambda interval: timedelta(months=interval), + 'minutes': lambda interval: timedelta(minutes=interval), + 'day': lambda interval: timedelta(days=interval), + 'hour': lambda interval: timedelta(hours=interval), + 'month': lambda interval: timedelta(months=interval), } base = get_datetime(base) d = base + fnct[rule.trg_date_range_type](rule.trg_date_range) if (not last_run or (last_run <= d < now)): self._action(cr, uid, [rule.id], [obj], context=context) - rule_pool.write(cr, uid, [rule.id], {'last_run': now}, context=context) + rule_pool.write(cr, uid, [rule.id], {'last_run': now}, + context=context) def format_body(self, body): """ Foramat Action rule's body From a53aeb5c0d7d7d5ec462f2cb709c616476945d07 Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 15:28:09 +0100 Subject: [PATCH 009/102] Make action date calculation clearer. bzr revid: daniel.watkins@credativ.co.uk-20100909142809-nrbt7f6sx3e86bxp --- addons/base_action_rule/base_action_rule.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 0e564915c7c..630cfca7e49 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -251,8 +251,9 @@ the rule to mark CC(mail to any other person defined in actions)."), 'month': lambda interval: timedelta(months=interval), } base = get_datetime(base) - d = base + fnct[rule.trg_date_range_type](rule.trg_date_range) - if (not last_run or (last_run <= d < now)): + delay = fnct[rule.trg_date_range_type](rule.trg_date_range) + action_date = base + delay + if (not last_run or (last_run <= action_date < now)): self._action(cr, uid, [rule.id], [obj], context=context) rule_pool.write(cr, uid, [rule.id], {'last_run': now}, context=context) From 5fc14722bb900337a6e7dfdcf0863246df50054a Mon Sep 17 00:00:00 2001 From: "Daniel Watkins (credativ)" Date: Thu, 9 Sep 2010 15:28:41 +0100 Subject: [PATCH 010/102] Don't run timed actions if we don't have a time base. bzr revid: daniel.watkins@credativ.co.uk-20100909142841-ntwee472cqr50t0i --- addons/base_action_rule/base_action_rule.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 630cfca7e49..cc7308dbc43 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -253,8 +253,8 @@ the rule to mark CC(mail to any other person defined in actions)."), base = get_datetime(base) delay = fnct[rule.trg_date_range_type](rule.trg_date_range) action_date = base + delay - if (not last_run or (last_run <= action_date < now)): - self._action(cr, uid, [rule.id], [obj], context=context) + if (not last_run or (last_run <= action_date < now)): + self._action(cr, uid, [rule.id], [obj], context=context) rule_pool.write(cr, uid, [rule.id], {'last_run': now}, context=context) From a051b28b34f682f98cbf774271436d01b77e3098 Mon Sep 17 00:00:00 2001 From: ssi Date: Thu, 4 Nov 2010 15:25:57 +0530 Subject: [PATCH 011/102] [IMP] modified partner search view bzr revid: ssi@tinyerp.com-20101104095557-q0r0y9a99w1t7dly --- bin/addons/base/res/partner/partner_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/addons/base/res/partner/partner_view.xml b/bin/addons/base/res/partner/partner_view.xml index 30bf8b49b98..da638182a0e 100644 --- a/bin/addons/base/res/partner/partner_view.xml +++ b/bin/addons/base/res/partner/partner_view.xml @@ -337,7 +337,7 @@ - + From d41debe92a44b3e1e92e7456b4b2b2a4a01c0aea Mon Sep 17 00:00:00 2001 From: ssi Date: Thu, 4 Nov 2010 15:29:30 +0530 Subject: [PATCH 012/102] [FIX]Audit: solved problem of audit creates ambigous menu entry lp bug: https://launchpad.net/bugs/670050 fixed bzr revid: ssi@tinyerp.com-20101104095930-gyolsnmd6hgm0rtk --- bin/addons/base/res/res_log_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/addons/base/res/res_log_view.xml b/bin/addons/base/res/res_log_view.xml index 4fc137eb26b..b67045f7daf 100644 --- a/bin/addons/base/res/res_log_view.xml +++ b/bin/addons/base/res/res_log_view.xml @@ -50,7 +50,7 @@ - Logs + Client Logs res.log form {'search_default_my': 1} From 462ca113382775124b48889f488d5f0e22767ba4 Mon Sep 17 00:00:00 2001 From: ssi Date: Thu, 4 Nov 2010 15:34:14 +0530 Subject: [PATCH 013/102] [FIX]partner:Improved wizard spam lp bug: https://launchpad.net/bugs/668320 fixed bzr revid: ssi@tinyerp.com-20101104100414-683dfu5i3avtq12z --- .../base/res/partner/wizard/partner_wizard_spam.py | 6 +++++- bin/tools/misc.py | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/res/partner/wizard/partner_wizard_spam.py b/bin/addons/base/res/partner/wizard/partner_wizard_spam.py index f349825d588..e194cb02316 100644 --- a/bin/addons/base/res/partner/wizard/partner_wizard_spam.py +++ b/bin/addons/base/res/partner/wizard/partner_wizard_spam.py @@ -22,6 +22,7 @@ import netsvc import tools from osv import fields, osv +import re class partner_wizard_spam(osv.osv_memory): """ Mass Mailing """ @@ -51,6 +52,9 @@ class partner_wizard_spam(osv.osv_memory): event_pool = self.pool.get('res.partner.event') active_ids = context and context.get('active_ids', []) partners = partner_pool.browse(cr, uid, active_ids, context) + type_ = 'plain' + if re.search('(<(pre)|[pubi].*>)', data.text): + type_ = 'html' for partner in partners: for adr in partner.address: if adr.email: @@ -58,7 +62,7 @@ class partner_wizard_spam(osv.osv_memory): to = '%s <%s>' % (name, adr.email) #TODO: add some tests to check for invalid email addresses #CHECKME: maybe we should use res.partner/email_send - tools.email_send(data.email_from, [to], data.subject, data.text,subtype='html') + tools.email_send(data.email_from, [to], data.subject, data.text,subtype=type_) nbr += 1 event_pool.create(cr, uid, {'name': 'Email(s) sent through mass mailing', diff --git a/bin/tools/misc.py b/bin/tools/misc.py index 8ce466338e9..4fd5f12fad9 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -38,6 +38,10 @@ import re from itertools import islice import threading from which import which +try: + from html2text import html2text +except ImportError: + html2text = None import smtplib from email.MIMEText import MIMEText @@ -532,7 +536,11 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non # Add dynamic X Header for key, value in x_headers.iteritems(): msg['%s' % key] = str(value) - + + if html2text and subtype == 'html': + text = html2text(body.decode('utf-8')).encode('utf-8') + msg.attach(MIMEText(text, _charset='utf-8', _subtype='plain')) + if attach: msg.attach(email_text) for (fname,fcontent) in attach: From d30c7f717615df9e93f0e51013b48a72679ac576 Mon Sep 17 00:00:00 2001 From: "Sbh (OpenERP)" Date: Fri, 3 Dec 2010 13:51:47 +0530 Subject: [PATCH 014/102] [IMP]crm: Remove cancle button bzr revid: sbh@tinyerp.com-20101203082147-qq476cmjx8woypjx --- addons/crm/crm_meeting_view.xml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index 2f215488c99..b44b146375a 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -133,14 +133,11 @@ -