diff --git a/addons/marketing_campaign/__openerp__.py b/addons/marketing_campaign/__openerp__.py index 44a2f1e30bd..44646a07ead 100644 --- a/addons/marketing_campaign/__openerp__.py +++ b/addons/marketing_campaign/__openerp__.py @@ -58,7 +58,11 @@ Note: If you need demo data, you can install the marketing_campaign_crm_demo mod "security/ir.model.access.csv" ], 'demo_xml': [ + 'marketing_campaign_demo.xml', ], + 'test': [ + 'test/marketing_campaign.yml', + ], 'installable': True, 'active': False, 'certificate' : '00421723279617928365', diff --git a/addons/marketing_campaign/marketing_campaign.py b/addons/marketing_campaign/marketing_campaign.py index 82832134c27..4e6f6a5227e 100644 --- a/addons/marketing_campaign/marketing_campaign.py +++ b/addons/marketing_campaign/marketing_campaign.py @@ -164,11 +164,12 @@ Normal - the campaign runs normally and automatically sends all emails and repor self.write(cr, uid, ids, {'state': 'cancelled'}) return True - + # dead code def signal(self, cr, uid, model, res_id, signal, run_existing=True, context=None): record = self.pool.get(model).browse(cr, uid, res_id, context) return self._signal(cr, uid, record, signal, run_existing, context) + #dead code def _signal(self, cr, uid, record, signal, run_existing=True, context=None): if not signal: raise ValueError('signal cannot be False') @@ -461,6 +462,7 @@ class marketing_campaign_activity(osv.osv): return super(marketing_campaign_activity, self).search(cr, uid, args, offset, limit, order, context, count) + #dead code def _process_wi_report(self, cr, uid, activity, workitem, context=None): service = netsvc.LocalService('report.%s'%activity.report_id.report_name) (report_data, format) = service.create(cr, uid, [], {}, {}) @@ -481,6 +483,7 @@ class marketing_campaign_activity(osv.osv): activity.email_template_id.id, workitem.res_id, context=context) + #dead code def _process_wi_action(self, cr, uid, activity, workitem, context=None): if context is None: context = {} @@ -670,7 +673,7 @@ class marketing_campaign_workitem(osv.osv): def _process_one(self, cr, uid, workitem, context=None): if workitem.state != 'todo': - return + return False activity = workitem.activity_id proxy = self.pool.get(workitem.object_id.model) @@ -707,7 +710,7 @@ class marketing_campaign_workitem(osv.osv): if result: # process _chain - workitem = workitem.browse(context)[0] # reload + workitem = workitem.browse(context=context)[0] # reload date = datetime.strptime(workitem.date, DT_FMT) for transition in activity.to_ids: @@ -784,11 +787,7 @@ class marketing_campaign_workitem(osv.osv): res = {} wi_obj = self.browse(cr, uid, ids[0], context=context) if wi_obj.activity_id.type == 'email': - data_obj = self.pool.get('ir.model.data') - data_id = data_obj._get_id(cr, uid, 'email_template', 'email_template_preview_form') - view_id = 0 - if data_id: - view_id = data_obj.browse(cr, uid, data_id, context=context).res_id + view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'email_template', 'email_template_preview_form') res = { 'name': _('Email Preview'), 'view_type': 'form', @@ -796,7 +795,7 @@ class marketing_campaign_workitem(osv.osv): 'res_model': 'email_template.preview', 'view_id': False, 'context': context, - 'views': [(view_id, 'form')], + 'views': [(view_id and view_id[1] or 0, 'form')], 'type': 'ir.actions.act_window', 'target': 'new', 'nodestroy':True, diff --git a/addons/marketing_campaign/marketing_campaign_demo.xml b/addons/marketing_campaign/marketing_campaign_demo.xml new file mode 100644 index 00000000000..aaf5a98c6bc --- /dev/null +++ b/addons/marketing_campaign/marketing_campaign_demo.xml @@ -0,0 +1,93 @@ + + + + + + Template for New Partner + info@tinyerp.com + Welcome in OpenERP Partner Channel! + ${object.email or ''} + + Hello, We are very happy to send Welcome message. + + + Template for Silver Partner + info@tinyerp.com + Congratulation! You become now our Silver Partner. + ${object.email or ''} + + Hello, We are happy to announce that you now become our Silver Partner. + + + + Template for Gold Partner + info@tinyerp.com + Congratulation! You become our Gold Partner. + ${object.email or ''} + + Hello, We are happy to announce that you become our Gold Partner. + + + + + + + OpenERP Partner Channel + + active + + + + + + New Partner + + + object.credit_limit < 10000 + True + + + + Silver Partner + + object.credit_limit >= 10000 and object.credit_limit < 50000 + True + + + + + Gold Partner + object.credit_limit >= 100000 + + True + + + + + + + + + + + + + + + + + + Partners + [('name','like','Agrolait')] + res.partner + + + + OpenERP Partner + create_date + + + + + + diff --git a/addons/marketing_campaign/test/marketing_campaign.yml b/addons/marketing_campaign/test/marketing_campaign.yml new file mode 100644 index 00000000000..1b7a7fa2ae3 --- /dev/null +++ b/addons/marketing_campaign/test/marketing_campaign.yml @@ -0,0 +1,151 @@ +- + In order to test process of compaign, I start compaign. +- + !workflow {model: marketing.campaign, action: state_running_set, ref: marketing_campaign_openerppartnerchannel} +- + I check the campaign on Running mode after started. +- + !assert {model: marketing.campaign, id: marketing_campaign_openerppartnerchannel}: + - state == 'running' +- + I start this segment after assinged campaign. +- + !workflow {model: marketing.campaign.segment, action: state_running_set, ref: marketing_campaign_segment0} +- + I check the segment on Running mode after started. +- + !assert {model: marketing.campaign.segment, id: marketing_campaign_segment0}: + - state == 'running' +- + I synchronized segment manually to see all step of activity and process covered on this campaign. +- + !python {model: marketing.campaign.segment}: | + segment_id = self.browse(cr ,uid ,ref("marketing_campaign_segment0") ,context) + assert segment_id.date_next_sync, 'Next Synchronization date is not calculated.' + self.synchroniz(cr, uid, [ref("marketing_campaign_segment0")]) +- + I cancel Marketing Workitems. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel'))]) + self.button_cancel(cr, uid, ids) + record = self.browse(cr, uid, ids[0]) + assert record.state == 'cancelled' or record.state == 'done' , 'Marketing Workitem shoud be in cancel state.' +- + I set Marketing Workitems in draft state. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel'))]) + self.button_draft(cr, uid, ids) + record = self.browse(cr, uid, ids[0]) + assert record.state == 'todo' or record.state == 'done' , 'Marketing Workitem shoud be in draft state.' +- + I check followup detail of first activity. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel')), ('activity_id', '=', ref('marketing_campaign_activity_0'))]) + assert ids, 'Followup item is not created for first activity.' + work_item_id = self.browse(cr ,uid ,ids[0] ,context) + assert work_item_id.res_name, 'Resource Name is not defined.' +- + I process followup of first activity. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel')), ('activity_id', '=', ref('marketing_campaign_activity_0'))]) + self.process(cr, uid, ids) + record = self.browse(cr, uid, ids)[0] + assert record.state == "done", "Followup item should be closed after process." +- + I check followup detail of second activity after process of first activity. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel')), ('activity_id', '=', ref('marketing_campaign_activity_1'))]) + assert ids, 'Followup item is not created for second activity.' +- + Now I increase credit limit of customer +- + !python {model: res.partner}: | + self.write(cr, uid, [ref("base.res_partner_agrolait")], {'credit_limit':41000}, context=context) +- + I process followup of second activity after set draft. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel')), ('activity_id', '=', ref('marketing_campaign_activity_1'))]) + self.button_draft(cr, uid, ids, context=context) + self.process(cr, uid, ids, context=context) + record = self.browse(cr, uid, ids[0], context=context) + assert record.state == "done", "Followup item should be closed after process." +- + I check followup detail of third activity after process of second activity. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel')), ('activity_id', '=', ref('marketing_campaign_activity_2'))]) + assert ids, 'Followup item is not created for third activity.' +- + Now I increase credit limit of customer +- + !python {model: res.partner}: | + self.write(cr, uid, [ref("base.res_partner_agrolait")], {'credit_limit':151000}, context=context) +- + I process followup of third activity after set draft. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel')), ('activity_id', '=', ref('marketing_campaign_activity_2'))]) + self.button_draft(cr, uid, ids, context=context) + self.process(cr, uid, ids, context=context) + record = self.browse(cr, uid, ids[0], context=context) + assert record.state == "done", "Followup item should be closed after process." +- + I print workitem report. +- + !python {model: marketing.campaign.workitem}: | + ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')), + ('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel')), ('activity_id', '=', ref('marketing_campaign_activity_2'))]) + self.preview(cr, uid, ids) +- + I cancel segmentation because of some activity. +- + !workflow {model: marketing.campaign.segment, action: state_cancel_set, ref: marketing_campaign_segment0} +- + I check the segmentation is canceled. +- + !assert {model: marketing.campaign.segment, id: marketing_campaign_segment0}: + - state == 'cancelled' +- + I reopen the segmentation. +- + !workflow {model: marketing.campaign.segment, action: state_draft_set, ref: marketing_campaign_segment0} +- + !workflow {model: marketing.campaign.segment, action: state_running_set, ref: marketing_campaign_segment0} +- + I check the segment on Running mode after started. +- + !assert {model: marketing.campaign.segment, id: marketing_campaign_segment0}: + - state == 'running' +- + I close segmentation After completion of all activity. +- + !workflow {model: marketing.campaign.segment, action: state_done_set, ref: marketing_campaign_segment0} +- + I check the segmentation is done. +- + !assert {model: marketing.campaign.segment, id: marketing_campaign_segment0}: + - state == 'done' +- + I close this campaing. +- + !workflow {model: marketing.campaign.segment, action: state_done_set, ref: marketing_campaign_openerppartnerchannel} +- + I check the campaing is done. +- + !assert {model: marketing.campaign.segment, id: marketing_campaign_openerppartnerchannel}: + - state == 'done' + diff --git a/addons/marketing_campaign_crm_demo/marketing_campaign_demo.xml b/addons/marketing_campaign_crm_demo/marketing_campaign_demo.xml index abf29f2c011..989d11e6ffd 100644 --- a/addons/marketing_campaign_crm_demo/marketing_campaign_demo.xml +++ b/addons/marketing_campaign_crm_demo/marketing_campaign_demo.xml @@ -58,7 +58,7 @@ For OpenERP Discovery Day on May 2010 - + Thanks for subscribing to the OpenERP Discovery Day info@tinyerp.com @@ -72,7 +72,7 @@ For OpenERP Discovery Day - + Thanks for buying the OpenERP book info@tinyerp.com @@ -91,7 +91,6 @@ info@tinyerp.com - Hello, We have very good offer that might suit you. For our gold partners,We are arranging free technical training on june,2010. @@ -157,6 +156,7 @@ OpenERP OnDemand Free Trial 2010 + active