[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
This commit is contained in:
parent
2128bb753a
commit
dc0b929b09
|
@ -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',
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -428,5 +428,262 @@
|
|||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Custom Case Sections -->
|
||||
<record id="crm_case_section_custom_view_form" model="ir.ui.view">
|
||||
<field name="name">crm.case.section.custom.form</field>
|
||||
<field name="model">crm.case.section.custom</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Custom Case Section">
|
||||
<group col="6" colspan="4">
|
||||
<field name="name" select="1" colspan="2"/>
|
||||
<field name="parent_id" select="2" widget="selection"/>
|
||||
<field name="code" select="1"/>
|
||||
<newline/>
|
||||
<field name="user_id" select="2"/>
|
||||
<field name="active" select="2"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Information">
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Mailgateway" colspan="2"/>
|
||||
<field name="reply_to" select="2"/>
|
||||
</group>
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Configuration" colspan="2"/>
|
||||
<field name="allow_unlink" select="2"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field name="note" select="1" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="crm_case_section_custom_view_tree" model="ir.ui.view">
|
||||
<field name="name">crm.case.section.custom.tree</field>
|
||||
<field name="model">crm.case.section.custom</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Custom Case Section">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Custom crm case-->
|
||||
|
||||
<record id="crm_case_custom_tree_view" model="ir.ui.view">
|
||||
<field name="name">Custom Cases - Tree</field>
|
||||
<field name="model">crm.case.custom</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="red:date_deadline<current_date and state=='open'" string="Custom Cases">
|
||||
<field name="id"/>
|
||||
<field name="date"/>
|
||||
<field name="date_deadline"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="user_id"/>
|
||||
<field name="priority"/>
|
||||
<field name="state"/>
|
||||
<field name="create_date" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="crm_case_custom_form_view" model="ir.ui.view">
|
||||
<field name="name">Custom Cases - Form</field>
|
||||
<field name="model">crm.case.custom</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority" eval="1"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Custom Cases">
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" select="1"/>
|
||||
<field name="section_id" widget="selection"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="priority"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="date_deadline" select="2"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="General">
|
||||
<group col="4" colspan="4">
|
||||
<separator string="Communication" colspan="4"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" select="1"/>
|
||||
<field name="partner_address_id" on_change="onchange_partner_address_id(partner_address_id, email_from)" select="2"/>
|
||||
<newline/>
|
||||
<field name="email_from" select="2"/>
|
||||
</group>
|
||||
|
||||
<separator string="Notes" colspan="4"/>
|
||||
<field colspan="4" name="description" nolabel="1" select="2"/>
|
||||
|
||||
<separator colspan="4"/>
|
||||
<group col="8" colspan="4">
|
||||
<field name="state"/>
|
||||
<button name="case_open" string="Open"
|
||||
states="draft,pending" type="object"
|
||||
icon="gtk-go-forward" />
|
||||
<button name="case_close" string="Close"
|
||||
states="open,draft,pending" type="object"
|
||||
icon="gtk-close" />
|
||||
<button name="case_pending" string="Pending"
|
||||
states="draft,open" type="object"
|
||||
icon="gtk-media-pause" />
|
||||
<button name="case_cancel" string="Cancel"
|
||||
states="draft,open,pending" type="object"
|
||||
icon="gtk-cancel" />
|
||||
<button name="case_reset"
|
||||
string="Reset to Draft" states="done,cancel"
|
||||
type="object" icon="gtk-convert" />
|
||||
</group>
|
||||
</page>
|
||||
<page string="Extra Info">
|
||||
<separator colspan="4" string="Dates"/>
|
||||
<field name="create_date"/>
|
||||
<field name="date_closed"/>
|
||||
<field name="date_action_last"/>
|
||||
<field name="date_action_next"/>
|
||||
<separator colspan="4" string="Others"/>
|
||||
<field name="id" select="1"/>
|
||||
<field name="active" select="2"/>
|
||||
<separator colspan="4" string="References"/>
|
||||
<field colspan="4" name="ref"/>
|
||||
<field colspan="4" name="log_ids" nolabel="1">
|
||||
<tree string="Logs">
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
</tree>
|
||||
<form string="Logs">
|
||||
<separator string="Action Information" colspan="4"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Emails" groups="base.group_extended">
|
||||
<group colspan="4">
|
||||
<field colspan="4" name="email_cc" string="CC" widget="char" size="512"/>
|
||||
</group>
|
||||
<field name="message_ids" colspan="4" nolabel="1" mode="form,tree">
|
||||
<form string="Communication history">
|
||||
<group col="4" colspan="4">
|
||||
<field name="email_from"/>
|
||||
<field name="date"/>
|
||||
<field name="email_to" widget="char" size="512"/>
|
||||
<field name="email_cc" widget="char" size="512"/>
|
||||
<field name="name" colspan="4" widget="char" size="512"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
<field name="description" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
<field name="attachment_ids" colspan="4" readonly="1" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<button colspan="4"
|
||||
string="Reply"
|
||||
name="%(crm.action_crm_send_mail)d"
|
||||
context="{'mail':'reply', 'model': 'crm.case.custom', 'include_original' : True}"
|
||||
icon="gtk-undo" type="action" />
|
||||
</form>
|
||||
<tree string="Communication history">
|
||||
<field name="date"/>
|
||||
<field name="email_from" />
|
||||
<field name="email_to"/>
|
||||
<field name="description"/>
|
||||
</tree>
|
||||
</field>
|
||||
<button colspan="2" string="Send New Email"
|
||||
name="%(crm.action_crm_send_mail)d"
|
||||
context="{'mail':'new', 'model': 'crm.case.custom'}"
|
||||
icon="gtk-go-forward" type="action" />
|
||||
<button colspan="2" string="Forward to Partner"
|
||||
name="%(crm_lead_forward_to_partner_act)d"
|
||||
icon="gtk-go-forward" type="action" />
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="crm_case_custom_calendar_view">
|
||||
<field name="name">Custom Cases - Calendar</field>
|
||||
<field name="model">crm.case.custom</field>
|
||||
<field name="type">calendar</field>
|
||||
<field name="priority" eval="2"/>
|
||||
<field name="arch" type="xml">
|
||||
<calendar string="Cases"
|
||||
date_start="date" color="user_id">
|
||||
<field name="name" />
|
||||
<field name="partner_id" />
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Custom Cases Search View -->
|
||||
|
||||
<record id="crm_case_custom_search_view" model="ir.ui.view">
|
||||
<field name="name">Custom Cases - Search</field>
|
||||
<field name="model">crm.case.custom</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Cases">
|
||||
<filter icon="terp-check"
|
||||
string="Current"
|
||||
default="1" name="current"
|
||||
domain="[('state','in',('draft','open'))]"/>
|
||||
<filter icon="terp-camera_test"
|
||||
string="Open"
|
||||
domain="[('state','=','open')]"/>
|
||||
<filter icon="terp-gtk-media-pause"
|
||||
string="Pending"
|
||||
domain="[('state','=','pending')]"/>
|
||||
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-go-today" string="Today"
|
||||
domain="[('create_date','<', time.strftime('%%Y-%%m-%%d 23:59:59')), ('create_date','>=', time.strftime('%%Y-%%m-%%d 00:00:00'))]"
|
||||
help="Todays' Cases" />
|
||||
<filter icon="terp-go-week" string="7 Days"
|
||||
help="Cases creating during last 7 days"
|
||||
domain="[('create_date','<', time.strftime('%%Y-%%m-%%d 23:59:59')),('create_date','>=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d 00:00:00'))]"
|
||||
/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="name"/>
|
||||
<field name="user_id">
|
||||
<filter icon="terp-personal-"
|
||||
domain="[('user_id','=', False)]"
|
||||
help="Unassigned Cases" />
|
||||
</field>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." groups="base.group_extended">
|
||||
<field name="create_date" string="Creation Date"/>
|
||||
<field name="date_closed"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
<filter string="Priority" icon="terp-rating-rated"
|
||||
domain="[]" context="{'group_by':'priority'}" />
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Salesman" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
|
||||
<filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Creation" icon="terp-go-month"
|
||||
domain="[]" context="{'group_by':'create_date'}" />
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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:
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="crm_custom_create_menu_form">
|
||||
<field name="name">crm.custom.create.menu.form</field>
|
||||
<field name="model">crm.custom.create.menu</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create Menu for Custom Cases">
|
||||
<separator string="Menu Information" colspan="4"/>
|
||||
<field name="name"/>
|
||||
<field name="menu_parent_id"/>
|
||||
<field name="section_id"/>
|
||||
<label string="This wizard will create all sub-menus, within the selected menu." align="0.0" colspan="4"/>
|
||||
<label string="You may want to create a new parent menu to put all the created menus in." align="0.0" colspan="4"/>
|
||||
<separator string="Select Views (Empty for default)" colspan="4"/>
|
||||
<field name="view_form"/>
|
||||
<field name="view_tree"/>
|
||||
<field name="view_calendar"/>
|
||||
<field name="view_search"/>
|
||||
<separator string="" colspan="4"/>
|
||||
<label string="" colspan="2"/>
|
||||
<button special="cancel" string="_Cancel" icon="gtk-cancel"/>
|
||||
<button name="menu_create" string="Create _Menu" type="object" icon='gtk-ok'/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="crm_custom_create_menu_action">
|
||||
<field name="name">Create Menu</field>
|
||||
<field name="res_model">crm.custom.create.menu</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="crm_custom_create_menu_action" id="crm_case_create_custom_menu" parent="base.menu_crm_config_sales"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue