diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py
index 4512892897f..98b43f1cd9c 100644
--- a/addons/crm/__openerp__.py
+++ b/addons/crm/__openerp__.py
@@ -84,6 +84,7 @@ Create dashboard for CRM that includes:
'wizard/crm_partner_to_opportunity_view.xml',
'wizard/crm_send_email_view.xml',
+ 'wizard/crm_add_note_view.xml',
'wizard/crm_forward_to_partner_view.xml',
'wizard/crm_custom_create_menu_view.xml',
'wizard/crm_merge_opportunities_view.xml',
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index 5014db61b85..737bb55b25e 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -211,11 +211,15 @@
-
-
+
diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index f11e5c98446..e0c0896a975 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -168,11 +168,15 @@
-
-
+
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index 6c9214ed395..fb8bddbb120 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -568,11 +568,15 @@
-
-
+
diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py
index 70dd08a23cf..9c14905076f 100644
--- a/addons/crm/wizard/__init__.py
+++ b/addons/crm/wizard/__init__.py
@@ -19,6 +19,7 @@
#
##############################################################################
+import crm_add_note
import crm_send_email
import crm_forward_to_partner
diff --git a/addons/crm/wizard/crm_add_note.py b/addons/crm/wizard/crm_add_note.py
new file mode 100644
index 00000000000..05ae3abc13d
--- /dev/null
+++ b/addons/crm/wizard/crm_add_note.py
@@ -0,0 +1,58 @@
+from crm import crm
+from osv import fields, osv
+from tools.translate import _
+
+
+AVAILABLE_STATES = crm.AVAILABLE_STATES + [('unchanged', 'Unchanged')]
+
+
+class crm_add_note(osv.osv_memory):
+ """Adds a new note to the case."""
+ _name = 'crm.add.note'
+ _description = "Add New Note"
+
+ _columns = {
+ 'body': fields.text('Note Body', required=True),
+ 'state': fields.selection(AVAILABLE_STATES, string='Set New State To',
+ required=True),
+ }
+
+ def action_add(self, cr, uid, ids, context=None):
+ if not context:
+ context = {}
+
+ if not context.get('active_model'):
+ raise osv.except_osv(_('Error'), _('Can not add note!'))
+
+ model = context.get('active_model')
+ case_pool = self.pool.get(model)
+
+ for obj in self.browse(cr, uid, ids, context=context):
+ case_list = case_pool.browse(cr, uid, context['active_ids'],
+ context=context)
+ case = case_list[0]
+ user_obj = self.pool.get('res.users')
+ user_name = user_obj.browse(cr, uid, [uid], context=context)[0].name
+ case_pool.history(cr, uid, [case], _("Note"), history=True,
+ details=obj.body, email_from=user_name)
+
+ if obj.state == 'unchanged':
+ pass
+ elif obj.state == 'done':
+ case_pool.case_close(cr, uid, [case.id])
+ elif obj.state == 'draft':
+ case_pool.case_reset(cr, uid, [case.id])
+ elif obj.state in ['cancel', 'open', 'pending']:
+ act = 'case_' + obj.state
+ getattr(case_pool, act)(cr, uid, [case.id])
+
+ return {}
+
+ def default_get(self, cr, uid, fields, context=None):
+ """
+ This function gets default values
+ """
+ return {'state': u'unchanged'}
+
+
+crm_add_note()
diff --git a/addons/crm/wizard/crm_add_note_view.xml b/addons/crm/wizard/crm_add_note_view.xml
new file mode 100644
index 00000000000..1e122c19760
--- /dev/null
+++ b/addons/crm/wizard/crm_add_note_view.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+ crm.new.add.note.form
+ crm.add.note
+ form
+
+
+
+
+
+
+
+
+ Add Note
+ crm.add.note
+ form
+ form
+
+ new
+
+
+
+
+
diff --git a/addons/crm/wizard/crm_send_email.py b/addons/crm/wizard/crm_send_email.py
index ae4e87f30ad..aadd607c154 100644
--- a/addons/crm/wizard/crm_send_email.py
+++ b/addons/crm/wizard/crm_send_email.py
@@ -28,6 +28,10 @@ import itertools
import tools
import re
+
+AVAILABLE_STATES = crm.AVAILABLE_STATES + [('unchanged', 'Unchanged')]
+
+
class crm_send_new_email_attachment(osv.osv_memory):
_name = 'crm.send.mail.attachment'
@@ -51,7 +55,7 @@ class crm_send_new_email(osv.osv_memory):
'email_cc' : fields.char('CC', size=512, help="These addresses will receive a copy of this email. To modify the permanent CC list, edit the global CC field of this case"),
'subject': fields.char('Subject', size=512, required=True),
'body': fields.text('Message Body', required=True),
- 'state': fields.selection(crm.AVAILABLE_STATES, string='Set New State To', required=True),
+ 'state': fields.selection(AVAILABLE_STATES, string='Set New State To', required=True),
'attachment_ids' : fields.one2many('crm.send.mail.attachment', 'wizard_id'),
}