From dc0b929b09a10ec5d06f14e8e0f0dc7cbbe38f80 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Sat, 10 Jul 2010 15:30:16 +0530 Subject: [PATCH] [ADD]: crm: * Added new objects for custom crm case and sections * Added a wizard to create Menus for custom cases bzr revid: rpa@tinyerp.com-20100710100016-n1tjsrvfnjgmifig --- addons/crm/__openerp__.py | 2 + addons/crm/crm.py | 82 ++++++ addons/crm/crm_view.xml | 257 ++++++++++++++++++ addons/crm/wizard/__init__.py | 2 + addons/crm/wizard/crm_custom_create_menu.py | 78 ++++++ .../wizard/crm_custom_create_menu_view.xml | 40 +++ 6 files changed, 461 insertions(+) create mode 100644 addons/crm/wizard/crm_custom_create_menu.py create mode 100644 addons/crm/wizard/crm_custom_create_menu_view.xml 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 + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +