diff --git a/poweremail_template.py b/poweremail_template.py
index 7eb3e35..ae3e106 100644
--- a/poweremail_template.py
+++ b/poweremail_template.py
@@ -634,6 +634,8 @@ def copy(self, cr, uid, id, default=None, context=None):
if check:
new_name = new_name + '_' + random.choice('abcdefghij') + random.choice('lmnopqrs') + random.choice('tuvwzyz')
default.update({'name':new_name})
+ # Clean no to copy values
+ default.update({'ref_ir_act_window':False, 'ref_ir_value': False})
return super(poweremail_templates, self).copy(cr, uid, id, default, context)
def compute_pl(self,
@@ -1178,6 +1180,23 @@ def create_action_reference(self, cursor, uid, ids, context):
'ref_ir_value': ref_ir_value,
}, context)
+ def remove_action_reference(self, cursor, uid, ids, context):
+ values_obj = self.pool.get('ir.values')
+ action_obj = self.pool.get('ir.actions.act_window')
+ template = self.pool.get('poweremail.templates').browse(
+ cursor, uid, ids[0]
+ )
+
+ if template.ref_ir_act_window:
+ action_id = template.ref_ir_act_window.id
+ template.write({'ref_ir_act_window': False})
+ action_obj.unlink(cursor, uid, action_id)
+
+ if template.ref_ir_value:
+ value_id = template.ref_ir_value.id
+ template.write({'ref_ir_value': False})
+ values_obj.unlink(cursor, uid, value_id)
+
poweremail_templates()
diff --git a/poweremail_template_view.xml b/poweremail_template_view.xml
index b47074d..340de64 100644
--- a/poweremail_template_view.xml
+++ b/poweremail_template_view.xml
@@ -148,6 +148,13 @@
attrs="{'readonly':[('ref_ir_act_window', '!=', False), ('ref_ir_value', '!=', False)]}"
icon="gtk-execute"
/>
+
diff --git a/tests/test_poweremail_templates.py b/tests/test_poweremail_templates.py
index dc1b2f0..a379275 100644
--- a/tests/test_poweremail_templates.py
+++ b/tests/test_poweremail_templates.py
@@ -96,4 +96,20 @@ def test_send_wizards_gets_default_priority_from_template(self):
'template_id': tmpl_id
})
wiz = send_obj.browse(cursor, uid, wiz_id)
- self.assertEqual(wiz.priority, '2')
\ No newline at end of file
+ self.assertEqual(wiz.priority, '2')
+
+ def test_remove_action_reference(self):
+ tmpl_obj = self.openerp.pool.get('poweremail.templates')
+ cursor = self.cursor
+ uid = self.uid
+ tmpl_id = self.create_template()
+ template = tmpl_obj.browse(cursor, uid, tmpl_id)
+ template.create_action_reference({})
+ template = tmpl_obj.browse(cursor, uid, tmpl_id)
+ self.assertTrue(template.ref_ir_act_window)
+ self.assertTrue(template.ref_ir_value)
+ template = tmpl_obj.browse(cursor, uid, tmpl_id)
+
+ template.remove_action_reference({})
+ self.assertFalse(template.ref_ir_act_window)
+ self.assertFalse(template.ref_ir_value)