[IMP] crm_phonecall: cleaned code, cleaned view.

bzr revid: tde@openerp.com-20120523150625-gk87cf9peq1remtc
This commit is contained in:
Thibault Delavallée 2012-05-23 17:06:25 +02:00
parent 08bddb434f
commit e902bd399b
2 changed files with 32 additions and 34 deletions

View File

@ -28,17 +28,13 @@ from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DA
from tools.translate import _
class crm_phonecall(crm_base, osv.osv):
""" Phonecall Cases """
""" Model for CRM phonecalls """
_name = "crm.phonecall"
_description = "Phonecall"
_order = "id desc"
_inherit = ['ir.needaction_mixin', 'mail.thread']
_columns = {
# From crm.case
'id': fields.integer('ID', readonly=True),
'name': fields.char('Call Summary', size=64, required=True),
'active': fields.boolean('Active', required=False),
# base_state required fields
'date_action_last': fields.datetime('Last Action', readonly=1),
'date_action_next': fields.datetime('Next Action', readonly=1),
'create_date': fields.datetime('Creation Date' , readonly=True),
@ -48,20 +44,21 @@ class crm_phonecall(crm_base, osv.osv):
'partner_id': fields.many2one('res.partner', 'Partner'),
'company_id': fields.many2one('res.company', 'Company'),
'description': fields.text('Description'),
'state': fields.selection([
('draft', 'Draft'),
('open', 'Todo'),
'state': fields.selection([ ('draft', 'Draft'),
('open', 'Confirmed'),
('pending', 'Not Held'),
('cancel', 'Cancelled'),
('done', 'Held'),
], 'Status', size=16, readonly=True,
help='The state is set to \'Todo\', when a case is created.\
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the call is over, the state is set to \'Held\'.\
\nIf the call needs to be done then the state is set to \'Not Held\'.'),
('done', 'Held'),],
string='Status', size=16, readonly=True,
help='The state is set to \'Todo\', when a case is created.\
If the case is in progress the state is set to \'Open\'.\
When the call is over, the state is set to \'Held\'.\
If the call needs to be done then the state is set to \'Not Held\'.'),
'email_from': fields.char('Email', size=128, help="These people will receive email."),
'date_open': fields.datetime('Opened', readonly=True),
# phonecall fields
'name': fields.char('Call Summary', size=64, required=True),
'active': fields.boolean('Active', required=False),
'duration': fields.float('Duration', help="Duration in Minutes"),
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="['|',('section_id','=',section_id),('section_id','=',False),\
@ -81,11 +78,10 @@ class crm_phonecall(crm_base, osv.osv):
return 'open'
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'date': fields.datetime.now,
'priority': crm.AVAILABLE_PRIORITIES[2][0],
'state': _get_default_state,
'user_id': lambda self,cr,uid,ctx: uid,
'active': 1,
}
def create(self, cr, uid, vals, context=None):
@ -96,8 +92,7 @@ class crm_phonecall(crm_base, osv.osv):
return obj_id
def case_close(self, cr, uid, ids, context=None):
"""Overrides close for crm_case for setting close date
"""
"""Overrides close for crm_case for setting close date """
res = True
for phone in self.browse(cr, uid, ids):
phone_id = phone.id
@ -116,7 +111,6 @@ class crm_phonecall(crm_base, osv.osv):
self.write(cr, uid, ids, {'duration': 0.0, 'state':'open'})
return res
def case_open(self, cr, uid, ids, context=None):
"""Overrides cancel for crm_case for setting Open Date
"""
@ -300,7 +294,7 @@ class crm_phonecall(crm_base, osv.osv):
return value
# ----------------------------------------
# OpenChatter methods and notifications
# OpenChatter
# ----------------------------------------
def get_needaction_user_ids(self, cr, uid, ids, context=None):
@ -336,9 +330,6 @@ class crm_phonecall(crm_base, osv.osv):
def _call_set_partner_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Partner has been <b>created</b>"), context=context)
crm_phonecall()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -43,10 +43,14 @@
states="open,pending" icon="gtk-redo"
name="action_make_meeting" type="object" />
<field name="state"/>
<button name="case_cancel" string="Cancel" states="open,pending" type="object" icon="gtk-cancel"/>
<button name="case_open" string="Todo" states="pending" type="object" icon="gtk-go-forward"/>
<button name="case_close" string="Held" states="open,pending" type="object" icon="gtk-jump-to"/>
<button name="case_pending" string="Not Held" states="open" type="object" icon="gtk-media-pause"/>
<button name="case_open" string="Confirm" type="object"
states="draft,pending" icon="gtk-go-forward"/>
<button name="case_close" string="Held" type="object"
states="open,pending" icon="gtk-jump-to"/>
<button name="case_reset" string="Reset to Todo" type="object"
states="cancel" icon="gtk-convert"/>
<button name="case_cancel" string="Cancel" type="object"
states="draft,open,pending" icon="gtk-cancel"/>
</tree>
</field>
</record>
@ -60,13 +64,16 @@
<field name="arch" type="xml">
<form layout="manual">
<div class="oe_form_topbar">
<button name="case_close" string="Held" states="open,pending" type="object" />
<button name="case_open" string="Todo" states="pending" type="object" />
<button name="case_pending" string="Not Held" states="open" type="object" />
<button name="case_reset" string="Reset to Todo" states="cancel" type="object" />
<button name="case_cancel" string="Cancel" states="open,pending" type="object" />
<button name="case_open" string="Confirm" type="object"
states="draft,pending" icon="gtk-go-forward"/>
<button name="case_close" string="Held" type="object"
states="open,pending" icon="gtk-jump-to"/>
<button name="case_reset" string="Reset to Todo" type="object"
states="cancel" icon="gtk-convert"/>
<button name="case_cancel" string="Cancel" type="object"
states="draft,open,pending" icon="gtk-cancel"/>
<div class="oe_right">
<field name="state" widget="statusbar" nolabel="1" statusbar_visible="open,done" statusbar_colors='{"pending":"red"}' select="1"/>
<field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,open,done" select="1"/>
</div>
<div class="oe_clear"/>
</div>