diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py
index a490a800beb..f23b61df5ea 100644
--- a/addons/crm/__openerp__.py
+++ b/addons/crm/__openerp__.py
@@ -85,6 +85,8 @@ Create dashboard for CRM that includes:
'wizard/crm_forward_to_partner_view.xml',
'wizard/crm_send_email_view.xml',
+ 'wizard/crm_custom_create_menu_view.xml',
+
'crm_view.xml',
'crm_action_rule_view.xml',
diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 575c2a8a3e3..9dd021183f4 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -639,4 +639,86 @@ class res_partner(osv.osv):
}
res_partner()
+
+class crm_case_section_custom(osv.osv):
+ _name = "crm.case.section.custom"
+ _description = 'Custom CRM Case Section'
+
+ _columns = {
+ 'name': fields.char('Case Section',size=64, required=True, translate=True),
+ 'code': fields.char('Section Code',size=8),
+ 'active': fields.boolean('Active'),
+ 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"),
+ 'sequence': fields.integer('Sequence'),
+ 'user_id': fields.many2one('res.users', 'Responsible User'),
+ 'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by Open ERP about cases in this section"),
+ 'parent_id': fields.many2one('crm.case.section', 'Parent Section'),
+ 'note': fields.text('Notes'),
+ }
+
+ _defaults = {
+ 'active': 1,
+ 'allow_unlink': 1,
+ }
+
+ _sql_constraints = [
+ ('code_uniq', 'unique (code)', 'The code of the section must be unique !')
+ ]
+
+ def _check_recursion(self, cr, uid, ids):
+ level = 100
+ while len(ids):
+ cr.execute('SELECT DISTINCT parent_id FROM crm_case_section '\
+ 'WHERE id IN %s',
+ (tuple(ids),))
+ ids = filter(None, map(lambda x:x[0], cr.fetchall()))
+ if not level:
+ return False
+ level -= 1
+ return True
+ _constraints = [
+ (_check_recursion, 'Error ! You cannot create recursive sections.', ['parent_id'])
+ ]
+
+crm_case_section_custom()
+
+
+class crm_case_custom(osv.osv, crm_case):
+ _name = 'crm.case.custom'
+ _inherit = 'mailgate.thread'
+ _description = "Custom CRM Case"
+
+ _columns = {
+ 'id': fields.integer('ID', readonly=True),
+ 'name': fields.char('Name',size=64,required=True),
+ 'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
+ 'active': fields.boolean('Active'),
+ 'description': fields.text('Description'),
+ 'section_id': fields.many2one('crm.case.section.custom', 'Section', required=True, select=True),
+ 'probability': fields.float('Probability (%)'),
+ 'email_from': fields.char('Partner Email', size=128),
+ 'email_cc': fields.char('CC', size=252),
+ 'partner_id': fields.many2one('res.partner', 'Partner'),
+ 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', domain="[('partner_id','=',partner_id)]"),
+ 'date': fields.datetime('Date'),
+ 'create_date': fields.datetime('Created' ,readonly=True),
+ 'date_deadline': fields.datetime('Deadline'),
+ 'date_closed': fields.datetime('Closed', readonly=True),
+ 'user_id': fields.many2one('res.users', 'Responsible'),
+ 'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True),
+ 'ref' : fields.reference('Reference', selection=_links_get, size=128),
+ 'date_action_last': fields.datetime('Last Action', readonly=1),
+ 'date_action_next': fields.datetime('Next Action', readonly=1),
+ }
+
+ _defaults = {
+ 'active': 1,
+ 'state': 'draft',
+ 'priority': AVAILABLE_PRIORITIES[2][0],
+ 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
+ }
+
+crm_case_custom()
+
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index 74786ad91f6..e42a3db0584 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -428,5 +428,262 @@
+
+
+
+
+ crm.case.section.custom.form
+ crm.case.section.custom
+ form
+
+
+
+
+
+ crm.case.section.custom.tree
+ crm.case.section.custom
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+ Custom Cases - Tree
+ crm.case.custom
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Custom Cases - Form
+ crm.case.custom
+ form
+
+
+
+
+
+
+
+ Custom Cases - Calendar
+ crm.case.custom
+ calendar
+
+
+
+
+
+
+
+
+
+
+
+
+ Custom Cases - Search
+ crm.case.custom
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py
index e4eb233a9b8..8c6a650b8da 100644
--- a/addons/crm/wizard/__init__.py
+++ b/addons/crm/wizard/__init__.py
@@ -30,5 +30,7 @@ import crm_phonecall_to_partner
import crm_phonecall_to_opportunity
import crm_partner_to_opportunity
+import crm_custom_create_menu
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/wizard/crm_custom_create_menu.py b/addons/crm/wizard/crm_custom_create_menu.py
new file mode 100644
index 00000000000..2d0bb8947f1
--- /dev/null
+++ b/addons/crm/wizard/crm_custom_create_menu.py
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 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 .
+#
+##############################################################################
+
+from osv import fields,osv
+
+
+class crm_case_custom_create_menu(osv.osv_memory):
+ '''
+ Create menu for custom Cases
+ '''
+ _name = 'crm.custom.create.menu'
+ _description = 'Create menu for custom Cases'
+
+ _columns = {
+ 'name': fields.char('Menu Name', size=64, required=True),
+ 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
+ 'section_id': fields.many2one('crm.case.section.custom', 'Section', required=True),
+ 'view_form': fields.many2one('ir.ui.view', 'Form View', domain=[('type','=','form'),('model','=','crm.case.custom')]),
+ 'view_tree': fields.many2one('ir.ui.view', 'Tree View', domain=[('type','=','tree'),('model','=','crm.case.custom')]),
+ 'view_calendar': fields.many2one('ir.ui.view', 'Calendar View', domain=[('type','=','calendar'),('model','=','crm.case.custom')]),
+ 'view_search': fields.many2one('ir.ui.view', 'Search View', domain=[('type','=','search'),('model','=','crm.case.custom')]),
+ }
+
+ def menu_create(self, cr, uid, ids, context=None):
+ """
+ Creates Menus for selected custom section
+ """
+ data_obj = self.pool.get('ir.model.data')
+ for this in self.browse(cr, uid, ids, context=context):
+ domain = [('section_id', '=', this.section_id)]
+ view_mode = [this.view_tree and 'tree', this.view_form and 'form', this.view_calendar and 'calendar']
+ view_mode = filter(None , view_mode)
+ action_id = self.pool.get('ir.actions.act_window').create(cr,uid, {
+ 'name': this.name,
+ 'res_model': 'crm.case.custom',
+ 'domain': domain,
+ 'view_type': 'form',
+ 'view_mode': ','.join(view_mode),
+ 'search_view_id': this.view_search.id or False,
+ 'context': {'default_section_id': this.section_id.id, 'default_user_id': uid}
+ })
+ menu_id=self.pool.get('ir.ui.menu').create(cr, uid, {
+ 'name': this.name,
+ 'parent_id': this.menu_parent_id.id,
+ 'icon': 'STOCK_JUSTIFY_FILL'
+ })
+ self.pool.get('ir.values').create(cr, uid, {
+ 'name': 'Custom Cases',
+ 'key2': 'tree_but_open',
+ 'model': 'ir.ui.menu',
+ 'res_id': menu_id,
+ 'value': 'ir.actions.act_window,%d'%action_id,
+ 'object': True
+ })
+ return {}
+
+crm_case_custom_create_menu()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/wizard/crm_custom_create_menu_view.xml b/addons/crm/wizard/crm_custom_create_menu_view.xml
new file mode 100644
index 00000000000..930a9eb99ec
--- /dev/null
+++ b/addons/crm/wizard/crm_custom_create_menu_view.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+