From f6d8ed277cb4e90a32dc6f95678e4b3494ef85e2 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 14 Jul 2010 12:14:58 +0200 Subject: [PATCH] [IMP] marketing_campaign: workitems are deleted if the condition is not met (unless explicitly keeped) bzr revid: chs@openerp.com-20100714101458-nor7umnxrza4hasn --- addons/marketing_campaign/marketing_campaign.py | 9 +++++++-- addons/marketing_campaign/marketing_campaign_view.xml | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/addons/marketing_campaign/marketing_campaign.py b/addons/marketing_campaign/marketing_campaign.py index c3bfbca7ce4..83e5ed4f19f 100644 --- a/addons/marketing_campaign/marketing_campaign.py +++ b/addons/marketing_campaign/marketing_campaign.py @@ -341,7 +341,9 @@ class marketing_campaign_activity(osv.osv): 'variable_cost': fields.float('Variable Cost'), 'revenue': fields.float('Revenue'), 'signal': fields.char('Signal', size=128, - help='An activity with a signal can be called programmatically. Attention, that always create the workiten'), + help='An activity with a signal can be called programmatically. Attention, the workitem is always created when the signal is send'), + 'keep_if_condition_not_met': fields.boolean('Keep if condition not met', + help="By activating this option, the workitems that aren't processed because the condition is not met are marked as cancelled instead of being deleted.") } _defaults = { @@ -543,7 +545,10 @@ class marketing_campaign_workitem(osv.osv): campaign_mode = workitem.campaign_id.mode if condition: if not eval(condition, eval_context): - workitem.write({'state': 'cancelled'}, context=context) + if activity.keep_if_condition_not_met: + workitem.write({'state': 'cancelled'}, context=context) + else: + workitem.unlink(context=context) return result = True if campaign_mode in ('manual', 'active'): diff --git a/addons/marketing_campaign/marketing_campaign_view.xml b/addons/marketing_campaign/marketing_campaign_view.xml index 4ac70292c32..1d07fc1e99c 100644 --- a/addons/marketing_campaign/marketing_campaign_view.xml +++ b/addons/marketing_campaign/marketing_campaign_view.xml @@ -228,7 +228,12 @@ - + + + + + +