[REF] crm_phonecall: removed inheritance towards base_state + some cleaning due to refactoring + changelog in crm/doc
bzr revid: tde@openerp.com-20130813084447-tb2j9uir3vzy0ddw
This commit is contained in:
parent
e8164c9a92
commit
2948a44a53
|
@ -19,21 +19,19 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from openerp.addons.base_status.base_state import base_state
|
|
||||||
import crm
|
import crm
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from openerp.osv import fields, osv
|
from openerp.osv import fields, osv
|
||||||
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
class crm_phonecall(base_state, osv.osv):
|
class crm_phonecall(osv.osv):
|
||||||
""" Model for CRM phonecalls """
|
""" Model for CRM phonecalls """
|
||||||
_name = "crm.phonecall"
|
_name = "crm.phonecall"
|
||||||
_description = "Phonecall"
|
_description = "Phonecall"
|
||||||
_order = "id desc"
|
_order = "id desc"
|
||||||
_inherit = ['mail.thread']
|
_inherit = ['mail.thread']
|
||||||
_columns = {
|
_columns = {
|
||||||
# base_state required fields
|
|
||||||
'date_action_last': fields.datetime('Last Action', readonly=1),
|
'date_action_last': fields.datetime('Last Action', readonly=1),
|
||||||
'date_action_next': fields.datetime('Next Action', readonly=1),
|
'date_action_next': fields.datetime('Next Action', readonly=1),
|
||||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||||
|
@ -43,16 +41,14 @@ class crm_phonecall(base_state, osv.osv):
|
||||||
'partner_id': fields.many2one('res.partner', 'Contact'),
|
'partner_id': fields.many2one('res.partner', 'Contact'),
|
||||||
'company_id': fields.many2one('res.company', 'Company'),
|
'company_id': fields.many2one('res.company', 'Company'),
|
||||||
'description': fields.text('Description'),
|
'description': fields.text('Description'),
|
||||||
'state': fields.selection([ ('draft', 'Draft'),
|
'state': fields.selection(
|
||||||
('open', 'Confirmed'),
|
[('open', 'Confirmed'),
|
||||||
('pending', 'Not Held'),
|
('cancel', 'Cancelled'),
|
||||||
('cancel', 'Cancelled'),
|
('done', 'Held')
|
||||||
('done', 'Held'),],
|
], string='Status', readonly=True, track_visibility='onchange',
|
||||||
string='Status', size=16, readonly=True, track_visibility='onchange',
|
help='The status is set to Confirmed, when a case is created.\n'
|
||||||
help='The status is set to \'Todo\', when a case is created.\
|
'When the call is over, the status is set to Held.\n'
|
||||||
If the case is in progress the status is set to \'Open\'.\
|
'If the callis not applicable anymore, the status can be set to Cancelled.'),
|
||||||
When the call is over, the status is set to \'Held\'.\
|
|
||||||
If the call needs to be done then the status is set to \'Not Held\'.'),
|
|
||||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||||
'date_open': fields.datetime('Opened', readonly=True),
|
'date_open': fields.datetime('Opened', readonly=True),
|
||||||
# phonecall fields
|
# phonecall fields
|
||||||
|
@ -71,7 +67,7 @@ class crm_phonecall(base_state, osv.osv):
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_default_state(self, cr, uid, context=None):
|
def _get_default_state(self, cr, uid, context=None):
|
||||||
if context and context.get('default_state', False):
|
if context and context.get('default_state'):
|
||||||
return context.get('default_state')
|
return context.get('default_state')
|
||||||
return 'open'
|
return 'open'
|
||||||
|
|
||||||
|
@ -79,29 +75,41 @@ class crm_phonecall(base_state, osv.osv):
|
||||||
'date': fields.datetime.now,
|
'date': fields.datetime.now,
|
||||||
'priority': crm.AVAILABLE_PRIORITIES[2][0],
|
'priority': crm.AVAILABLE_PRIORITIES[2][0],
|
||||||
'state': _get_default_state,
|
'state': _get_default_state,
|
||||||
'user_id': lambda self,cr,uid,ctx: uid,
|
'user_id': lambda self, cr, uid, ctx: uid,
|
||||||
'active': 1
|
'active': 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def on_change_partner_id(self, cr, uid, ids, partner_id, context=None):
|
||||||
|
values = {}
|
||||||
|
if partner_id:
|
||||||
|
partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
|
||||||
|
values = {
|
||||||
|
'partner_phone': partner.phone,
|
||||||
|
'partner_mobile': partner.mobile,
|
||||||
|
}
|
||||||
|
return {'value': values}
|
||||||
|
|
||||||
def case_close(self, cr, uid, ids, context=None):
|
def case_close(self, cr, uid, ids, context=None):
|
||||||
""" Overrides close for crm_case for setting duration """
|
|
||||||
res = True
|
|
||||||
for phone in self.browse(cr, uid, ids, context=context):
|
for phone in self.browse(cr, uid, ids, context=context):
|
||||||
phone_id = phone.id
|
data = {
|
||||||
data = {}
|
'state': 'done',
|
||||||
if phone.duration <=0:
|
'date_closed': fields.datetime.now(),
|
||||||
|
}
|
||||||
|
if phone.duration <= 0:
|
||||||
duration = datetime.now() - datetime.strptime(phone.date, DEFAULT_SERVER_DATETIME_FORMAT)
|
duration = datetime.now() - datetime.strptime(phone.date, DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
data['duration'] = duration.seconds/float(60)
|
data['duration'] = duration.seconds/float(60)
|
||||||
res = super(crm_phonecall, self).case_close(cr, uid, [phone_id], context=context)
|
self.write(cr, uid, [phone.id], data, context=context)
|
||||||
self.write(cr, uid, [phone_id], data, context=context)
|
return True
|
||||||
return res
|
|
||||||
|
|
||||||
def case_reset(self, cr, uid, ids, context=None):
|
def case_reset(self, cr, uid, ids, context=None):
|
||||||
"""Resets case as Todo
|
data = {
|
||||||
"""
|
'state': 'open',
|
||||||
res = super(crm_phonecall, self).case_reset(cr, uid, ids, context)
|
'duration': 0.0,
|
||||||
self.write(cr, uid, ids, {'duration': 0.0, 'state':'open'}, context=context)
|
}
|
||||||
return res
|
return self.write(cr, uid, ids, data, context=context)
|
||||||
|
|
||||||
|
def case_cancel(self, cr, uid, ids, context=None):
|
||||||
|
return self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
|
||||||
|
|
||||||
def schedule_another_phonecall(self, cr, uid, ids, schedule_time, call_summary, \
|
def schedule_another_phonecall(self, cr, uid, ids, schedule_time, call_summary, \
|
||||||
user_id=False, section_id=False, categ_id=False, action='schedule', context=None):
|
user_id=False, section_id=False, categ_id=False, action='schedule', context=None):
|
||||||
|
|
|
@ -105,8 +105,7 @@
|
||||||
<field name="duration" widget="float_time"/>
|
<field name="duration" widget="float_time"/>
|
||||||
<field name="section_id" colspan="1" widget="selection"
|
<field name="section_id" colspan="1" widget="selection"
|
||||||
groups="base.group_multi_salesteams"/>
|
groups="base.group_multi_salesteams"/>
|
||||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
|
<field name="partner_id" on_change="on_change_partner_id(partner_id)"/>
|
||||||
<field name="email_from" invisible="1"/> <!--not needed because of the chatter, thus invisible, but must be in the view as it's returned by onchange_partner_id()-->
|
|
||||||
<field name="categ_id" widget="selection"
|
<field name="categ_id" widget="selection"
|
||||||
domain="[('object_id.model', '=', 'crm.phonecall')]"/>
|
domain="[('object_id.model', '=', 'crm.phonecall')]"/>
|
||||||
<field name="partner_mobile"/>
|
<field name="partner_mobile"/>
|
||||||
|
|
|
@ -8,6 +8,7 @@ Changelog
|
||||||
|
|
||||||
- Stage/state update
|
- Stage/state update
|
||||||
|
|
||||||
|
- ``crm.phonecall``: removed inheritance towards ``base_state``.
|
||||||
- ``crm.lead``: removed ``state`` field. Added ``date_last_stage_update`` field
|
- ``crm.lead``: removed ``state`` field. Added ``date_last_stage_update`` field
|
||||||
holding last stage_id modification. Updated reports.
|
holding last stage_id modification. Updated reports.
|
||||||
- ``crm.case.stage``: removed ``state`` field.
|
- ``crm.case.stage``: removed ``state`` field.
|
||||||
|
|
Loading…
Reference in New Issue