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" /> +