Improved CRM module
bzr revid: fp@tinyerp.com-99aa34c24fdee8fb8b4750986cbee42c7489ff9a
This commit is contained in:
+34
-16
@@ -229,7 +229,7 @@ class crm_case(osv.osv):
|
||||
'name': fields.char('Case Description',size=64, required=True),
|
||||
'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'active': fields.boolean('Active'),
|
||||
'description': fields.text('Description'),
|
||||
'description': fields.text('Your action'),
|
||||
'section_id': fields.many2one('crm.case.section', 'Case Section', required=True, select=True),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id)]"),
|
||||
'planned_revenue': fields.float('Planned Revenue'),
|
||||
@@ -247,7 +247,8 @@ class crm_case(osv.osv):
|
||||
'date_closed': fields.datetime('Date Closed', readonly=True),
|
||||
'canal_id': fields.many2one('res.partner.canal', 'Channel'),
|
||||
'user_id': fields.many2one('res.users', 'User Responsible'),
|
||||
'history_line': fields.one2many('crm.case.history', 'case_id', 'Case History'),
|
||||
'history_line': fields.one2many('crm.case.history', 'case_id', 'Communication'),
|
||||
'log_ids': fields.one2many('crm.case.log', 'case_id', 'Logs History'),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
|
||||
'ref' : fields.reference('Reference', selection=_links_get, size=128),
|
||||
'ref2' : fields.reference('Reference 2', selection=_links_get, size=128),
|
||||
@@ -400,16 +401,21 @@ class crm_case(osv.osv):
|
||||
})
|
||||
return True
|
||||
|
||||
def __history(self, cr, uid, cases, keyword, context={}):
|
||||
def __history(self, cr, uid, cases, keyword, history=False, email=False, context={}):
|
||||
for case in cases:
|
||||
self.pool.get('crm.case.history').create(cr, uid, {
|
||||
data = {
|
||||
'name': keyword,
|
||||
'description': case.description,
|
||||
'som': False,
|
||||
'canal_id': False,
|
||||
'user_id': uid,
|
||||
'case_id': case.id
|
||||
})
|
||||
}
|
||||
obj = self.pool.get('crm.case.log')
|
||||
if history:
|
||||
obj = self.pool.get('crm.case.history')
|
||||
data['description'] = case.description
|
||||
data['email'] = False
|
||||
obj.create(cr, uid, data, context)
|
||||
return True
|
||||
|
||||
def create(self, cr, uid, *args, **argv):
|
||||
@@ -450,17 +456,17 @@ class crm_case(osv.osv):
|
||||
)
|
||||
return True
|
||||
|
||||
def case_log(self, cr, uid, ids, *args):
|
||||
def case_log(self, cr, uid, ids, email=False, *args):
|
||||
cases = self.browse(cr, uid, ids)
|
||||
self.__history(cr, uid, cases, '')
|
||||
self.__history(cr, uid, cases, 'Communication', history=True, email=email)
|
||||
return self.write(cr, uid, ids, {'description':False, 'som':False, 'canal_id': False})
|
||||
|
||||
def case_log_reply(self, cr, uid, ids, *args):
|
||||
def case_log_reply(self, cr, uid, ids, email=False, *args):
|
||||
cases = self.browse(cr, uid, ids)
|
||||
for case in cases:
|
||||
if not case.email_from:
|
||||
raise osv.except_osv('Error !', 'You must put a Partner eMail to use this action !')
|
||||
self.__history(cr, uid, cases, '')
|
||||
self.__history(cr, uid, cases, 'Communication', history=True, email=False)
|
||||
for case in cases:
|
||||
self.write(cr, uid, [case.id], {'description':False, 'som':False, 'canal_id': False, 'email_last':case.description})
|
||||
emails = [case.email_from] + (case.email_cc or '').split(',')
|
||||
@@ -558,20 +564,32 @@ class crm_case(osv.osv):
|
||||
return True
|
||||
crm_case()
|
||||
|
||||
class crm_case_history(osv.osv):
|
||||
_name = "crm.case.history"
|
||||
_description = "Case history"
|
||||
class crm_case_log(osv.osv):
|
||||
_name = "crm.case.log"
|
||||
_description = "Case communication history"
|
||||
_order = "id desc"
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64),
|
||||
'description': fields.text('Description'),
|
||||
'som': fields.many2one('res.partner.som', 'State of Mind'),
|
||||
'date': fields.date('Date'),
|
||||
'date': fields.datetime('Date'),
|
||||
'canal_id': fields.many2one('res.partner.canal', 'Channel'),
|
||||
'user_id': fields.many2one('res.users', 'User Responsible', readonly=True),
|
||||
'case_id': fields.many2one('crm.case', 'Case', required=True, ondelete='cascade')
|
||||
}
|
||||
_defaults = {
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
}
|
||||
crm_case_log()
|
||||
|
||||
class crm_case_history(osv.osv):
|
||||
_name = "crm.case.history"
|
||||
_description = "Case history"
|
||||
_order = "id desc"
|
||||
_inherits = {'crm.case.log':"log_id"}
|
||||
_columns = {
|
||||
'description': fields.text('Description'),
|
||||
'email': fields.char('Email', size=84),
|
||||
'log_id': fields.many2one('crm.case.log','Log'),
|
||||
}
|
||||
crm_case_history()
|
||||
|
||||
|
||||
+28
-5
@@ -186,6 +186,21 @@
|
||||
# ------------------------------------------------------
|
||||
# Cases
|
||||
# ------------------------------------------------------
|
||||
<record model="ir.ui.view" id="crm_case_log_tree-view">
|
||||
<field name="name">crm.case.log.tree</field>
|
||||
<field name="model">crm.case.log</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Case logs">
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="som"/>
|
||||
<field name="user_id"/>
|
||||
<field name="canal_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="crm_case_history_tree-view">
|
||||
<field name="name">crm.case.history.tree</field>
|
||||
@@ -244,10 +259,8 @@
|
||||
<group col="2" colspan="2">
|
||||
<button name="remind_partner" string="Send Reminder" states="open,pending" type="object"/>
|
||||
</group>
|
||||
<separator string="Next Action" colspan="4"/>
|
||||
|
||||
<field name="description" colspan="4" select="2"/>
|
||||
<field name="som" select="2"/>
|
||||
<field name="canal_id"/>
|
||||
<field name="date_deadline" select="2"/>
|
||||
|
||||
<group col="2" colspan="2">
|
||||
@@ -264,6 +277,15 @@
|
||||
<button name="case_escalate" string="Escalate" states="open,draft,pending" type="object"/>
|
||||
<button name="case_reset" string="Reset to Draft" states="done,cancel" type="object"/>
|
||||
</group>
|
||||
<field name="history_line" colspan="4" nolabel="1" mode="form,tree">
|
||||
<form string="Communication">
|
||||
<field name="user_id" select="2"/>
|
||||
<field name="date" select="2"/>
|
||||
<field name="email" select="2"/>
|
||||
<newline/>
|
||||
<field name="description" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</page><page string="References">
|
||||
<field name="id" select="1"/>
|
||||
<field name="categ_id" select="2" on_change="onchange_categ_id(categ_id)"/>
|
||||
@@ -271,6 +293,8 @@
|
||||
<field name="active" select="2"/>
|
||||
<field name="ref" colspan="4"/>
|
||||
<field name="ref2" colspan="4"/>
|
||||
<field name="som" select="2"/>
|
||||
<field name="canal_id"/>
|
||||
<field name="planned_revenue"/>
|
||||
<field name="planned_cost"/>
|
||||
<field name="probability"/>
|
||||
@@ -281,7 +305,7 @@
|
||||
<field name="email_cc" colspan="4"/>
|
||||
<field name="email_last" colspan="4"/>
|
||||
</page><page string="History">
|
||||
<field name="history_line" nolabel="1" colspan="4" widget="one2many_list">
|
||||
<field name="log_ids" nolabel="1" colspan="4">
|
||||
<form string="Actions">
|
||||
<separator string="Action Information" colspan="4"/>
|
||||
<field name="name" colspan="4"/>
|
||||
@@ -289,7 +313,6 @@
|
||||
<field name="user_id" select="2"/>
|
||||
<field name="som" select="2"/>
|
||||
<field name="canal_id"/>
|
||||
<field name="description" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user