[FIX] marketing_campaign : view and error on email,server action fix
bzr revid: dhara@dhara-laptop-20100624105950-gg15cr9gbuufqaj0
This commit is contained in:
parent
e2a068e03f
commit
fe0030c8f5
|
@ -73,11 +73,19 @@ you required for the campaign"),
|
|||
campaign = self.browse(cr, uid, ids[0])
|
||||
if not campaign.activity_ids :
|
||||
raise osv.except_osv("Error", "There is no activitity in the campaign")
|
||||
act_ids = [ act_id.id for act_id in campaign.activity_ids]
|
||||
act_ids = self.pool.get('marketing.campaign.activity').search(cr, uid,
|
||||
[('id', 'in', act_ids), ('start', '=', True)])
|
||||
actvity_ids = [ act_id.id for act_id in campaign.activity_ids]
|
||||
act_obj = self.pool.get('marketing.campaign.activity')
|
||||
act_ids = act_obj.search(cr, uid, [('id', 'in', actvity_ids),
|
||||
('start', '=', True)])
|
||||
if not act_ids :
|
||||
raise osv.except_osv("Error", "There is no starting activitity in the campaign")
|
||||
act_ids = act_obj.search(cr, uid, [('id', 'in', actvity_idsf),
|
||||
('type', '=', 'email')])
|
||||
for activity in act_obj.browse(cr, uid, act_ids):
|
||||
if not activity.email_template_id.enforce_from_account :
|
||||
raise osv.except_osv("Error", "Campaign cannot be start : Email Account is missing in email activity")
|
||||
if activity.email_template_id.enforce_from_account.state != 'approved' :
|
||||
raise osv.except_osv("Error", "Campaign cannot be start : Email Account is not approved for email activity")
|
||||
self.write(cr, uid, ids, {'state': 'running'})
|
||||
return True
|
||||
|
||||
|
@ -239,7 +247,7 @@ class marketing_campaign_activity(osv.osv):
|
|||
def __init__(self, *args):
|
||||
self._actions = {'paper' : self.process_wi_report,
|
||||
'email' : self.process_wi_email,
|
||||
'server_action' : self.process_wi_action,
|
||||
'action' : self.process_wi_action,
|
||||
}
|
||||
return super(marketing_campaign_activity, self).__init__(*args)
|
||||
|
||||
|
@ -273,13 +281,15 @@ class marketing_campaign_activity(osv.osv):
|
|||
return True
|
||||
|
||||
def process_wi_email(self, cr, uid, activity, workitem, context=None):
|
||||
return self.pool.get('email.template').generate_mail(cr, uid, activity.email_template_id.id, [workitem.res_id], context=context)
|
||||
return self.pool.get('email.template').generate_mail(cr, uid,
|
||||
activity.email_template_id.id,
|
||||
[workitem.res_id], context=context)
|
||||
|
||||
def process_wi_action(self, cr, uid, activity, workitem, context={}):
|
||||
context = {}
|
||||
server_obj = self.pool.get('ir.actions.server')
|
||||
server_obj.run(cr, uid, [activity.server_action_id.id], context)
|
||||
return True
|
||||
context['active_id'] = workitem.res_id
|
||||
return server_obj.run(cr, uid, [activity.server_action_id.id], context)
|
||||
|
||||
def process(self, cr, uid, act_id, wi_id, context={}):
|
||||
activity = self.browse(cr, uid, act_id)
|
||||
|
@ -339,7 +349,7 @@ class marketing_campaign_workitem(osv.osv):
|
|||
type='many2one', relation='marketing.campaign', string='Campaign', readonly=True),
|
||||
'object_id': fields.related('segment_id', 'campaign_id', 'object_id',
|
||||
type='many2one', relation='ir.model', string='Object', select=1),
|
||||
'res_id': fields.integer('Resource ID', select=1),
|
||||
'res_id': fields.integer('Resource ID', select=1, readonly=1),
|
||||
'res_name': fields.function(_res_name_get, method=True, string='Resource Name', type="char", size=64),
|
||||
'date': fields.datetime('Execution Date'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', select=1),
|
||||
|
@ -408,7 +418,7 @@ class marketing_campaign_workitem(osv.osv):
|
|||
else:
|
||||
vals = {'state': 'exception'}
|
||||
if type(result) == type({}) and 'error_msg' in result:
|
||||
vals['error_msg'] = result['error_msg']
|
||||
vals['error_msg'] = result['error_msg']
|
||||
self.write(cr, uid, wi.id, vals)
|
||||
else:
|
||||
self.write(cr, uid, wi.id, {'state': 'cancelled'})
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
<field name="name" select="1" />
|
||||
<field name="start"/>
|
||||
<field name="variable_cost" select="1"/>
|
||||
<field name="object_id" invisible="1"/>
|
||||
</group>
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Condition" colspan="2"/>
|
||||
|
@ -44,7 +45,7 @@
|
|||
<field name="report_directory_id" attrs="{'required':[('type','=','paper')]}" />
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible':[('type','!=','action')]}" >
|
||||
<field name="server_action_id" attrs="{'required':[('type','=','action')]}" />
|
||||
<field name="server_action_id" attrs="{'required':[('type','=','action')]}" domain="[('model_id','=',object_id)]" />
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible':[('type','!=','subcampaign')]}" >
|
||||
<field name="subcampaign_id" attrs="{'required':[('type','=','subcampaign')]}" />
|
||||
|
@ -366,6 +367,7 @@
|
|||
<field name="partner_id"/>
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
<button string="Preview" states="todo" name="preview" icon="gtk-apply" type="object"/>
|
||||
<button string="Process" states="todo" name="process" type="object" icon="gtk-ok"/>
|
||||
<button string="Cancel" states="todo" name="button_cancel" type="object" icon="gtk-cancel"/>
|
||||
</tree>
|
||||
|
|
Loading…
Reference in New Issue