[FIX] view and button for the action wizard on email_tempalte

bzr revid: dhara@dhara-laptop-20100625095231-dk8p4oobvvonceyd
This commit is contained in:
Dhara 2010-06-25 15:22:31 +05:30
parent 3d20973c46
commit bcb1b02c10
5 changed files with 28 additions and 10 deletions

View File

@ -222,39 +222,41 @@ class email_template(osv.osv):
'template_language' : lambda *a:'mako', 'template_language' : lambda *a:'mako',
} }
_sql_constraints = [ _sql_constraints = [
('name', 'unique (name)', _('The template name must be unique !')) ('name', 'unique (name)', _('The template name must be unique !'))
] ]
def create(self, cr, uid, vals, context=None): def create_action(self, cr, uid, ids, context):
id = super(email_template, self).create(cr, uid, vals, context) vals = {}
src_obj = self.pool.get('ir.model').read(cr, uid, vals['object_name'], ['model'], context)['model'] template_obj = self.browse(cr, uid, ids)[0]
src_obj = template_obj.object_name.model
vals['ref_ir_act_window'] = self.pool.get('ir.actions.act_window').create(cr, uid, { vals['ref_ir_act_window'] = self.pool.get('ir.actions.act_window').create(cr, uid, {
'name': _("%s Mail Form") % vals['name'], 'name': _("%s Mail Form") % template_obj.name,
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'email_template.send.wizard', 'res_model': 'email_template.send.wizard',
'src_model': src_obj, 'src_model': src_obj,
'view_type': 'form', 'view_type': 'form',
'context': "{'src_model':'%s','template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, id), 'context': "{'src_model':'%s','template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, template_obj.id),
'view_mode':'form,tree', 'view_mode':'form,tree',
'view_id': self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'email_template.send.wizard.form')], context=context)[0], 'view_id': self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'email_template.send.wizard.form')], context=context)[0],
'target': 'new', 'target': 'new',
'auto_refresh':1 'auto_refresh':1
}, context) }, context)
vals['ref_ir_value'] = self.pool.get('ir.values').create(cr, uid, { vals['ref_ir_value'] = self.pool.get('ir.values').create(cr, uid, {
'name': _('Send Mail (%s)') % vals['name'], 'name': _('Send Mail (%s)') % template_obj.name,
'model': src_obj, 'model': src_obj,
'key2': 'client_action_multi', 'key2': 'client_action_multi',
'value': "ir.actions.act_window," + str(vals['ref_ir_act_window']), 'value': "ir.actions.act_window," + str(vals['ref_ir_act_window']),
'object': True, 'object': True,
}, context) }, context)
self.write(cr, uid, id, { self.write(cr, uid, ids, {
'ref_ir_act_window': vals['ref_ir_act_window'], 'ref_ir_act_window': vals['ref_ir_act_window'],
'ref_ir_value': vals['ref_ir_value'], 'ref_ir_value': vals['ref_ir_value'],
}, context) }, context)
return id return True
def unlink(self, cr, uid, ids, context=None): def unlink_action(self, cr, uid, ids, context):
for template in self.browse(cr, uid, ids, context): for template in self.browse(cr, uid, ids, context):
obj = self.pool.get(template.object_name.model) obj = self.pool.get(template.object_name.model)
try: try:
@ -264,6 +266,13 @@ class email_template(osv.osv):
self.pool.get('ir.values').unlink(cr, uid, template.ref_ir_value.id, context) self.pool.get('ir.values').unlink(cr, uid, template.ref_ir_value.id, context)
except: except:
raise osv.except_osv(_("Warning"), _("Deletion of Record failed")) raise osv.except_osv(_("Warning"), _("Deletion of Record failed"))
def delete_action(self, cr, uid, ids, context):
self.unlink_action(cr, uid, ids, context)
return True
def unlink(self, cr, uid, ids, context=None):
self.unlink_action(cr, uid, ids, context)
return super(email_template, self).unlink(cr, uid, ids, context) return super(email_template, self).unlink(cr, uid, ids, context)
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):

View File

@ -41,6 +41,7 @@ class email_template_mailbox(osv.osv):
return True return True
def send_this_mail(self, cr, uid, ids=None, context=None): def send_this_mail(self, cr, uid, ids=None, context=None):
result = True
for id in (ids or []): for id in (ids or []):
try: try:
account_obj = self.pool.get('email_template.account') account_obj = self.pool.get('email_template.account')

View File

@ -114,6 +114,10 @@
<field name="file_name" colspan="2" /> <field name="file_name" colspan="2" />
<field name="report_template" colspan="2" <field name="report_template" colspan="2"
domain="[('model','=',model_int_name)]" /> domain="[('model','=',model_int_name)]" />
<group colspan="2">
<button name="create_action" string="Create Action" type="object" colspan="1" attrs="{'invisible':[('ref_ir_act_window','!=',False), ('ref_ir_value','!=',False)]}"/>
<button name="delete_action" string="Delete Action" type="object" colspan="1" attrs="{'invisible':[('ref_ir_act_window','=',False), ('ref_ir_value','=',False)]}"/>
</group>
</page> </page>
</notebook> </notebook>
</form> </form>

View File

@ -289,7 +289,9 @@ class marketing_campaign_activity(osv.osv):
context = {} context = {}
server_obj = self.pool.get('ir.actions.server') server_obj = self.pool.get('ir.actions.server')
context['active_id'] = workitem.res_id context['active_id'] = workitem.res_id
return server_obj.run(cr, uid, [activity.server_action_id.id], context) res = server_obj.run(cr, uid, [activity.server_action_id.id], context)
#server action return False if the action is perfomed except client_action,other and python code
return res==False and True or res
def process(self, cr, uid, act_id, wi_id, context={}): def process(self, cr, uid, act_id, wi_id, context={}):
activity = self.browse(cr, uid, act_id) activity = self.browse(cr, uid, act_id)

View File

@ -2,6 +2,8 @@
<openerp> <openerp>
<data> <data>
<menuitem name="Configuration" id="menu_marketing_configuration" parent="marketing.marketing_menu" sequence="1"/>
<!-- <!--
====================== ======================
Marketing Campaign Marketing Campaign