Rohan Nayani(Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-coverage-marketing-ron into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-coverage-marketing-ron/+merge/82637


* Clean test cases of Yml Marketing Module:
=============================

marketing_campaign.yml => Process for marketing campaign running, add to 
specific segmentation for this campaign, synchronize of segmentation after that 
close segmentation and comping.

* Improved demo data of Email template.
* Fixed Traceback when Traceback generate when processing workitem.
* Improved code.

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-coverage-marketing-ron/+merge/82637
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-coverage-marketing-ron.
=== modified file 'marketing_campaign/marketing_campaign.py'
--- marketing_campaign/marketing_campaign.py	2011-10-16 01:28:00 +0000
+++ marketing_campaign/marketing_campaign.py	2011-11-18 06:01:28 +0000
@@ -707,7 +707,7 @@
 
             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 +784,7 @@
         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 +792,7 @@
                 '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,

=== modified file 'marketing_campaign_crm_demo/__openerp__.py'
--- marketing_campaign_crm_demo/__openerp__.py	2011-10-11 20:05:49 +0000
+++ marketing_campaign_crm_demo/__openerp__.py	2011-11-18 06:01:28 +0000
@@ -40,6 +40,10 @@
     'demo_xml': [
         'marketing_campaign_demo.xml',
     ],
+    'test': [
+            'test/process/marketing_campaign.yml',
+            'test/ui/onchange_events.yml'
+             ],
     'installable': True,
     'active': False,
     'certificate' : '001005497972871352957',

=== modified file 'marketing_campaign_crm_demo/marketing_campaign_demo.xml'
--- marketing_campaign_crm_demo/marketing_campaign_demo.xml	2011-01-14 00:11:01 +0000
+++ marketing_campaign_crm_demo/marketing_campaign_demo.xml	2011-11-18 06:01:28 +0000
@@ -34,27 +34,27 @@
 
         <!-- Email tempalte -->
         <record id="email_template_1" model="email.template">
-            <field name="def_subject">Thanks for showing interest in OpenERP</field>
-            <field name="def_to">[email protected]</field>
+            <field name="subject">Thanks for showing interest in OpenERP</field>
+            <field name="email_to">[email protected]</field>
             <field eval="[(6,0,[])]" name="allowed_groups"/>
             <field model="ir.actions.act_window" name="ref_ir_act_window" search="[('name', '=', u'For OpenERP OnDemand Free Trial 2010 Mail Form')]"/>
             <field model="ir.values" name="ref_ir_value" search="[('name', '=', u'Send Mail (For OpenERP OnDemand Free Trial 2010)')]"/>
-            <field name="object_name" ref="crm.model_crm_lead"/>
+            <field name="model_id" ref="crm.model_crm_lead"/>
             <field eval="0" name="use_sign"/>
-            <field name="def_body_text">Hello,Thanks for generous interest you have shown in the openERP.Regards,OpenERP Team,</field>
+            <field name="body_text">Hello,Thanks for generous interest you have shown in the openERP.Regards,OpenERP Team,</field>
             <field name="template_language">mako</field>
             <field name="name">For OpenERP OnDemand Free Trial 2010</field>
             <field name="model_int_name">crm.lead</field>
         </record>
         <record id="email_template_2" model="email.template">
-            <field name="def_subject">Propose to subscribe to the OpenERP Discovery Day on May 2010</field>
-            <field name="def_to">[email protected]</field>
+            <field name="subject">Propose to subscribe to the OpenERP Discovery Day on May 2010</field>
+            <field name="email_to">[email protected]</field>
             <field eval="[(6,0,[])]" name="allowed_groups"/>
             <field model="ir.actions.act_window" name="ref_ir_act_window" search="[('name', '=', u'For OpenERP OnDemand Free Trial 2010 Mail Form')]"/>
             <field model="ir.values" name="ref_ir_value" search="[('name', '=', u'Send Mail (For OpenERP OnDemand Free Trial 2010)')]"/>
-            <field name="object_name" ref="crm.model_crm_lead"/>
+            <field name="model_id" ref="crm.model_crm_lead"/>
             <field eval="0" name="use_sign"/>
-            <field name="def_body_text">Hello,We have very good offer that might suit you.
+            <field name="body_text">Hello,We have very good offer that might suit you.
             We propose you to subscribe to the OpenERP Discovery Day on May 2010.
             If any further information required kindly revert back.
             We really appreciate your co-operation on this.
@@ -65,14 +65,14 @@
         </record>
 
             <record id="email_template_3" model="email.template">
-            <field name="def_subject">Thanks for subscribing to the OpenERP Discovery Day</field>
-            <field name="def_to">[email protected]</field>
+            <field name="subject">Thanks for subscribing to the OpenERP Discovery Day</field>
+            <field name="email_to">[email protected]</field>
             <field eval="[(6,0,[])]" name="allowed_groups"/>
             <field model="ir.actions.act_window" name="ref_ir_act_window" search="[('name', '=', u'For OpenERP OnDemand Free Trial 2010 Mail Form')]"/>
             <field model="ir.values" name="ref_ir_value" search="[('name', '=', u'Send Mail (For OpenERP OnDemand Free Trial 2010)')]"/>
-            <field name="object_name" ref="crm.model_crm_lead"/>
+            <field name="model_id" ref="crm.model_crm_lead"/>
             <field eval="0" name="use_sign"/>
-            <field name="def_body_text">Hello,Thanks for showing intrest and for subscribing to the OpenERP Discovery Day.
+            <field name="body_text">Hello,Thanks for showing intrest and for subscribing to the OpenERP Discovery Day.
              If any further information required kindly revert back.
              I really appreciate your co-operation on this.
              Regards,OpenERP Team,</field>
@@ -82,14 +82,14 @@
         </record>
 
              <record id="email_template_4" model="email.template">
-            <field name="def_subject">Thanks for buying the OpenERP book</field>
-            <field name="def_to">[email protected]</field>
+            <field name="subject">Thanks for buying the OpenERP book</field>
+            <field name="email_to">[email protected]</field>
             <field eval="[(6,0,[])]" name="allowed_groups"/>
             <field model="ir.actions.act_window" name="ref_ir_act_window" search="[('name', '=', u'For OpenERP OnDemand Free Trial 2010 Mail Form')]"/>
            <field model="ir.values" name="ref_ir_value" search="[('name', '=', u'Send Mail (For OpenERP OnDemand Free Trial 2010)')]"/>
-             <field name="object_name" ref="crm.model_crm_lead"/>
+             <field name="model_id" ref="crm.model_crm_lead"/>
             <field eval="0" name="use_sign"/>
-            <field name="def_body_text">Hello,Thanks for showing intrest and buying the OpenERP book.
+            <field name="body_text">Hello,Thanks for showing intrest and buying the OpenERP book.
             If any further information required kindly revert back.
             I really appreciate your co-operation on this.
             Regards,OpenERP Team,</field>
@@ -99,14 +99,14 @@
         </record>
 
          <record id="email_template_5" model="email.template">
-            <field name="def_subject">Propose a free technical training to Gold partners</field>
-            <field name="def_to">[email protected]</field>
+            <field name="subject">Propose a free technical training to Gold partners</field>
+            <field name="email_to">[email protected]</field>
             <field eval="[(6,0,[])]" name="allowed_groups"/>
             <field model="ir.actions.act_window" name="ref_ir_act_window" search="[('name', '=', u'For OpenERP OnDemand Free Trial 2010 Mail Form')]"/>
             <field model="ir.values" name="ref_ir_value" search="[('name', '=', u'Send Mail (For OpenERP OnDemand Free Trial 2010)')]"/>
-            <field name="object_name" ref="crm.model_crm_lead"/>
+            <field name="model_id" ref="crm.model_crm_lead"/>
             <field eval="0" name="use_sign"/>
-            <field name="def_body_text">Hello, We have very good offer that might suit you.
+            <field name="body_text">Hello, We have very good offer that might suit you.
             For our gold partners,We are arranging free technical training on june,2010.
             If any further information required kindly revert back.
             I really appreciate your co-operation on this.
@@ -117,14 +117,14 @@
         </record>
 
           <record id="email_template_6" model="email.template">
-            <field name="def_subject">Propose paid training to Silver partners</field>
-            <field name="def_to">[email protected]</field>
+            <field name="subject">Propose paid training to Silver partners</field>
+            <field name="email_to">[email protected]</field>
             <field eval="[(6,0,[])]" name="allowed_groups"/>
             <field model="ir.actions.act_window" name="ref_ir_act_window" search="[('name', '=', u'For OpenERP OnDemand Free Trial 2010 Mail Form')]"/>
             <field model="ir.values" name="ref_ir_value" search="[('name', '=', u'Send Mail (For OpenERP OnDemand Free Trial 2010)')]"/>
-            <field name="object_name" ref="crm.model_crm_lead"/>
+            <field name="model_id" ref="crm.model_crm_lead"/>
             <field eval="0" name="use_sign"/>
-            <field name="def_body_text">Hello, We have very good offer that might suit you.
+            <field name="body_text">Hello, We have very good offer that might suit you.
             For our silver partners,We are  paid technical training on june,2010.
             If any further information required kindly revert back.
             I really appreciate your co-operation on this.
@@ -135,14 +135,14 @@
         </record>
 
         <record id="email_template_7" model="email.template">
-            <field name="def_subject">Propose gold partnership to silver partners</field>
-            <field name="def_to">[email protected]</field>
+            <field name="subject">Propose gold partnership to silver partners</field>
+            <field name="email_to">[email protected]</field>
             <field eval="[(6,0,[])]" name="allowed_groups"/>
             <field model="ir.actions.act_window" name="ref_ir_act_window" search="[('name', '=', u'For OpenERP OnDemand Free Trial 2010 Mail Form')]"/>
             <field model="ir.values" name="ref_ir_value" search="[('name', '=', u'Send Mail (For OpenERP OnDemand Free Trial 2010)')]"/>
-            <field name="object_name" ref="crm.model_crm_lead"/>
+            <field name="model_id" ref="crm.model_crm_lead"/>
             <field eval="0" name="use_sign"/>
-            <field name="def_body_text">Hello, We have very good offer that might suit you.
+            <field name="body_text">Hello, We have very good offer that might suit you.
             For our silver partners,We are  offering Gold partnership.
             If any further information required kindly revert back.
             I really appreciate your co-operation on this.
@@ -153,14 +153,14 @@
         </record>
 
         <record id="email_template_8" model="email.template">
-            <field name="def_subject">Thanks for subscribing to technical training</field>
-            <field name="def_to">[email protected]</field>
+            <field name="subject">Thanks for subscribing to technical training</field>
+            <field name="email_to">[email protected]</field>
             <field eval="[(6,0,[])]" name="allowed_groups"/>
             <field model="ir.actions.act_window" name="ref_ir_act_window" search="[('name', '=', u'For OpenERP OnDemand Free Trial 2010 Mail Form')]"/>
             <field model="ir.values" name="ref_ir_value" search="[('name', '=', u'Send Mail (For OpenERP OnDemand Free Trial 2010)')]"/>
-            <field name="object_name" ref="crm.model_crm_lead"/>
+            <field name="model_id" ref="crm.model_crm_lead"/>
             <field eval="0" name="use_sign"/>
-            <field name="def_body_text">Hello, Thanks for showing intrest and for subscribing to technical training.If any further information required kindly revert back.I really appreciate your co-operation on this.
+            <field name="body_text">Hello, Thanks for showing intrest and for subscribing to technical training.If any further information required kindly revert back.I really appreciate your co-operation on this.
             Regards,OpenERP Team,</field>
             <field name="template_language">mako</field>
             <field name="name">For subscribing to technical training</field>
@@ -181,6 +181,7 @@
         <record id="marketing_campaign_openerpondemandfreetrial0" model="marketing.campaign">
             <field name="name">OpenERP OnDemand Free Trial 2010</field>
             <field name="object_id" ref="crm.model_crm_lead"/>
+            <field name="mode">active</field>
             <field name="partner_field_id" ref="crm.field_crm_lead_partner_id"/>
         </record>
 

=== added directory 'marketing_campaign_crm_demo/test'
=== added directory 'marketing_campaign_crm_demo/test/process'
=== added file 'marketing_campaign_crm_demo/test/process/marketing_campaign.yml'
--- marketing_campaign_crm_demo/test/process/marketing_campaign.yml	1970-01-01 00:00:00 +0000
+++ marketing_campaign_crm_demo/test/process/marketing_campaign.yml	2011-11-18 06:01:28 +0000
@@ -0,0 +1,57 @@
+-
+  I created marketing campaing with specific activity(offers) to reach our partners 
+  and communication via email according to campaing activity.
+  Now I start this compaign.
+-
+  !workflow {model: marketing.campaign, action: state_running_set, ref: marketing_campaign_openerpondemandfreetrial0}
+-
+  I check the campaign on Running mode.
+-
+  !assert {model: marketing.campaign, id: marketing_campaign_openerpondemandfreetrial0}:
+    - state == 'running'
+-
+  This campaign is only for Belgium partner of leads, so I assinged this Campaign 
+  to right segment(Only for Belgium Leads), after that I start this segment. 
+-
+  !workflow {model: marketing.campaign.segment, action: state_running_set, ref: marketing_campaign_segment_bosslistusassociationslist0}
+-
+  I check the segment on Running mode.
+-
+  !assert {model: marketing.campaign.segment, id: marketing_campaign_segment_bosslistusassociationslist0}:
+    - state == 'running'
+-
+  I synchronized this segment manually to see all step of activity and process covered on this campaign.
+-
+  !python {model: marketing.campaign.segment}: |
+    self.synchroniz(cr, uid, [ref("marketing_campaign_segment_bosslistusassociationslist0")])
+-
+  I process the event of belgium partner which is particiapated with our campaing activity, 
+  after processing the event, automatic email send to that partner with specific message and check
+  the status of event.
+-
+  !python {model: marketing.campaign.workitem}: |
+    ids = self.search(cr, uid, [('res_id', '=', ref('crm.crm_case_ericdubois4')), ('segment_id', '=', ref('marketing_campaign_segment_bosslistusassociationslist0')),
+    ('campaign_id', '=', ref('marketing_campaign_openerpondemandfreetrial0')), ('activity_id', '=', ref('marketing_campaign_activity_1'))])
+    assert ids, 'Activity items not created'
+    self.process(cr, uid, ids)
+    record = self.browse(cr, uid, ids)[0]
+    assert record.state == "done", "Activity item not in done state"
+-
+  After completion of all activity i close segmentation first.
+-
+  !workflow {model: marketing.campaign.segment, action: state_done_set, ref: marketing_campaign_segment_bosslistusassociationslist0}
+-
+  I check the segmentation is done.
+-
+  !assert {model: marketing.campaign.segment, id: marketing_campaign_segment_bosslistusassociationslist0}:
+    - state == 'done'
+-
+  I close this campaing.
+-
+  !workflow {model: marketing.campaign.segment, action: state_done_set, ref: marketing_campaign_openerpondemandfreetrial0}
+-
+  I check the campaing is done.
+-
+  !assert {model: marketing.campaign.segment, id: marketing_campaign_openerpondemandfreetrial0}:
+    - state == 'done'
+    
\ No newline at end of file

=== added directory 'marketing_campaign_crm_demo/test/ui'
=== added file 'marketing_campaign_crm_demo/test/ui/onchange_events.yml'
--- marketing_campaign_crm_demo/test/ui/onchange_events.yml	1970-01-01 00:00:00 +0000
+++ marketing_campaign_crm_demo/test/ui/onchange_events.yml	2011-11-18 06:01:28 +0000
@@ -0,0 +1,12 @@
+-
+  I call onchange event to change campaing for segment.
+-
+  !python {model: marketing.campaign.segment}: |
+    self.onchange_campaign_id(cr, uid, [ref("marketing_campaign_segment_bosslistusassociationslist0")], ref("marketing_campaign_openerpondemandfreetrial0"))
+-
+  I can see preview report of workitem.
+-
+  !python {model: marketing.campaign.workitem}: |
+    ids = self.search(cr, uid, [('res_id', '=', ref('crm.crm_case_ericdubois4')), ('segment_id', '=', ref('marketing_campaign_segment_bosslistusassociationslist0')),
+    ('campaign_id', '=', ref('marketing_campaign_openerpondemandfreetrial0')), ('activity_id', '=', ref('marketing_campaign_activity_2'))])
+    self.preview(cr, uid, ids)

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to