diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index a57ffcd272c..673b14fe65d 100755
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -1039,5 +1039,43 @@ class crm_email_history(osv.osv):
_order = 'id desc'
crm_email_history()
+
+class crm_email_add_cc_wizard(osv.osv_memory):
+ _name = "crm.email.add.cc"
+ _description = "Email Add CC"
+ _columns = {
+ 'name': fields.selection([('user','User'),('partner','Partner'),('email','Email Address')], 'Send to', required=True),
+ 'user_id': fields.many2one('res.users',"User"),
+ 'partner_id': fields.many2one('res.partner',"Partner"),
+ 'email': fields.char('Email', size=32),
+ }
+
+ def change_email(self, cr, uid, ids, user, partner):
+ if (not partner and not user):
+ return {'value':{'email': False}}
+ email = False
+ if partner:
+ addr = self.pool.get('res.partner').address_get(cr, uid, [partner], ['contact'])
+ if addr:
+ email = self.pool.get('res.partner.address').read(cr, uid,addr['contact'] , ['email'])['email']
+ elif user:
+ addr = self.pool.get('res.users').read(cr, uid, user, ['address_id'])['address_id']
+ if addr:
+ email = self.pool.get('res.partner.address').read(cr, uid,addr[0] , ['email'])['email']
+ return {'value':{'email': email}}
+
+
+ def add_cc(self, cr, uid, ids, context={}):
+ email = self.read(cr, uid, ids[0])['email']
+ if not context:
+ return {}
+ history_line = self.pool.get('crm.case.history').browse(cr, uid, context['active_id'])
+ crm_case = self.pool.get('crm.case')
+ case_id = history_line.log_id.case_id.id
+ crm_case.write(cr, uid, case_id, {'email_cc' : email})
+ return {}
+
+crm_email_add_cc_wizard()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index fdb79ed5d73..156ac40aa3a 100755
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -239,11 +239,37 @@
-
+
+ Add CC
+ crm.email.add.cc
+ form
+
+
+
+
+
+
+ Add CC
+ ir.actions.act_window
+ crm.email.add.cc
+ form
+ form
+ new
+
@@ -395,8 +421,8 @@
diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py
index 55f1d9a3a7c..b29cbe06375 100644
--- a/addons/crm/wizard/__init__.py
+++ b/addons/crm/wizard/__init__.py
@@ -23,7 +23,6 @@ import crm_wizard
import wizard_crm_send_email
import wizard_crm_new_send_email
import wizard_fetch_mail
-import wizard_add_cc
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/wizard/wizard_add_cc.py b/addons/crm/wizard/wizard_add_cc.py
deleted file mode 100644
index 2848126f9c2..00000000000
--- a/addons/crm/wizard/wizard_add_cc.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-
-import time
-import wizard
-import osv
-import pooler
-
-cc_form = '''
-'''
-
-#on_change="change_email(user_id, partner_id)"
-
-cc_fields = {
- 'send_to' : {'string' : 'Send to', 'type' : 'selection', 'required' :True, \
- 'selection' :[('user','User'),('partner','Partner'),('email','Email Address')], \
- 'default' : 'email'},
- 'user_id' : {'string' : 'User', 'type' : 'many2one', 'relation' : 'res.users'},
- 'partner_id' : {'string' : 'Partner', 'type' : 'many2one', 'relation' : 'res.partner'},
- 'email' : {'string' : 'Email', 'type' : 'char', 'size' : 24},
-}
-
-#def change_email(self, cr, uid, data, context):
-# return {}
-
-def email_cc_add(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- history_line = pool.get('crm.case.history').browse(cr, uid, data['id'])
- crm_case = pool.get('crm.case')
- case_id = history_line.log_id.case_id.id
- crm_case.write(cr, uid, case_id, {'email_cc' : data['form']['email']})
- #TODO: send the latest email to the email adderss
- return {}
-
-
-class wizard_add_cc(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form', 'arch' : cc_form, 'fields' :cc_fields,\
- 'state' :[('end','Cancel', 'gtk-cancel'),('add','Ok', 'gtk-go-forward' )]}
- },
- 'add' : {
- 'actions' : [email_cc_add],
- 'result' : {'type' : 'state', 'state' : 'end'}
- }
- }
-wizard_add_cc('crm.case.email.add_cc')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-