[MERGE] crm-imp2

bzr revid: tfr@openerp.com-20110616155606-jdd72ptu08v645id
This commit is contained in:
tfr@openerp.com
2011-06-16 17:56:06 +02:00
17 changed files with 122 additions and 250 deletions
+7 -6
View File
@@ -331,8 +331,6 @@ class crm_case(object):
if not case.user_id:
data['user_id'] = uid
self.write(cr, uid, case.id, data)
self._action(cr, uid, cases, 'open')
return True
@@ -423,11 +421,14 @@ class crm_case(object):
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
state = 'draft'
if 'crm.phonecall' in args:
state = 'open'
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
self._history(cr, uid, cases, _('Draft'))
self.write(cr, uid, ids, {'state': 'draft', 'active': True})
self._action(cr, uid, cases, 'draft')
self.write(cr, uid, ids, {'state': state, 'active': True})
self._action(cr, uid, cases, state)
return True
def remind_partner(self, cr, uid, ids, context=None, attach=False):
@@ -454,9 +455,9 @@ class crm_case(object):
"""
for case in self.browse(cr, uid, ids, context=context):
if not destination and not case.email_from:
raise osv.except_osv(_('Error!'), ("Partner Email is not specified in Case"))
return False
if not case.user_id.user_email:
raise osv.except_osv(_('Error!'), ("User Email is not specified in Case"))
return False
if destination and case.section_id.user_id:
case_email = case.section_id.user_id.user_email
+1 -1
View File
@@ -143,7 +143,7 @@ class crm_lead(crm_case, osv.osv):
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Campaign', \
domain="['|',('section_id','=',section_id),('section_id','=',False)]"),
'channel_id': fields.many2one('res.partner.canal', 'Channel'),
'channel_id': fields.many2one('res.partner.canal', 'Lead Source'),
'contact_name': fields.char('Contact Name', size=64),
'partner_name': fields.char("Customer Name", size=64,help='The name of the future partner that will be created while converting the into opportunity'),
+1 -1
View File
@@ -334,7 +334,7 @@
domain="[('user_id','=', False)]"
help="Unassigned Leads" />
</field>
<field name="subjects"/>
<field name="subjects" groups="base.group_extended"/>
<field name="section_id" widget="selection"
context="{'invisible_section': False}">
<filter icon="terp-personal+" groups="base.group_extended"
+3 -2
View File
@@ -132,7 +132,7 @@
<group colspan="2" col="2">
<separator string="Mailings" colspan="2"/>
<field name="optin" on_change="on_change_optin(optin)"/>
<field name="optout" on_change="on_change_optout(optout)"/>
<field name="optout" on_change="on_change_optout(optout)"/>
</group>
</page>
@@ -310,7 +310,7 @@
domain="[]"
help="Show Sales Team"/>
</field>
<field name="subjects"/>
<newline/>
<group expand="0" string="Extended Filters..." groups="base.group_extended">
<field name="stage_id" widget="selection" domain="[('type', '=', 'opportunity')]"/>
@@ -326,6 +326,7 @@
<newline/>
<field name="create_date" string="Creation Date"/>
<field name="date_closed"/>
<field name="subjects"/>
</group>
<newline/>
<group expand="0" string="Group By..." colspan="16">
+12 -7
View File
@@ -53,10 +53,10 @@ class crm_phonecall(crm_case, osv.osv):
('draft', 'Draft'),
('open', 'Todo'),
('cancel', 'Cancelled'),
('done', 'Done'),
('pending', 'Pending'),
('done', 'Held'),
('pending', 'Not Held'),
], 'State', size=16, readonly=True,
help='The state is set to \'Draft\', when a case is created.\
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 case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
@@ -79,14 +79,19 @@ class crm_phonecall(crm_case, osv.osv):
the canall which is this opportunity source."),
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'opportunity_id': fields.many2one ('crm.lead', 'Opportunity'),
'opportunity_id': fields.many2one ('crm.lead', 'Lead/Opportunity'),
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
}
def _get_default_state(self, cr, uid, context=None):
if context and context.get('default_state', False):
return context.get('default_state')
return 'open'
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'priority': crm.AVAILABLE_PRIORITIES[2][0],
'state': 'open',
'state': _get_default_state,
'user_id': lambda self,cr,uid,ctx: uid,
'active': 1,
}
@@ -122,14 +127,14 @@ class crm_phonecall(crm_case, osv.osv):
return res
def case_reset(self, cr, uid, ids, *args):
"""Resets case as draft
"""Resets case as Todo
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
res = super(crm_phonecall, self).case_reset(cr, uid, ids, args)
res = super(crm_phonecall, self).case_reset(cr, uid, ids, args, 'crm.phonecall')
self.write(cr, uid, ids, {'duration': 0.0})
return res
+3
View File
@@ -18,6 +18,7 @@
<field name="categ_id" ref="crm.categ_phone1"/>
<field eval="&quot;(769) 703-274&quot;" name="partner_phone"/>
<field eval="2.3" name="duration"/>
<field eval="&quot;done&quot;" name="state"/>
</record>
<record id="crm_case_phone02" model="crm.phonecall">
<field name="partner_address_id" ref="base.res_partner_address_6"/>
@@ -33,6 +34,7 @@
<field name="categ_id" ref="crm.categ_phone1"/>
<field eval="&quot;(956) 293-2595&quot;" name="partner_phone"/>
<field eval="1.5" name="duration"/>
<field eval="&quot;done&quot;" name="state"/>
</record>
<record id="crm_case_phone03" model="crm.phonecall">
<field name="partner_address_id" ref="base.res_partner_address_2"/>
@@ -49,6 +51,7 @@
<field eval="&quot;(079) 681-2139&quot;" name="partner_phone"/>
<field eval="&quot;contact@tecsas.fr&quot;" name="email_from"/>
<field eval="5.0" name="duration"/>
<field eval="&quot;done&quot;" name="state"/>
</record>
<record id="crm_case_phone04" model="crm.phonecall">
<field eval="time.strftime('%Y-%m-21 14:10:23')" name="date"/>
+13 -13
View File
@@ -4,7 +4,7 @@
<act_window
id="crm_case_categ_phone_create_partner"
name="Schedule Phone Call"
name="Schedule a Call"
res_model="crm.phonecall"
src_model="res.partner"
view_mode="calendar,tree,form"
@@ -61,15 +61,15 @@
parent="base.menu_base_partner" sequence="4" />
<record model="ir.actions.act_window" id="crm_case_categ_phone_incoming0">
<field name="name">Inbound</field>
<field name="name">Logged Calls</field>
<field name="res_model">crm.phonecall</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar</field>
<field name="view_id" ref="crm_case_phone_tree_view"/>
<field name="domain" eval="'[(\'categ_id\',\'=\','+str(ref('categ_phone1'))+')]'"/>
<field name="context" eval="'{\'search_default_section_id\':section_id, \'default_state\':\'open\', \'search_default_current\':1,\'search_default_today\':1, \'default_categ_id\': ' + str(ref('categ_phone1')) +'}'"/>
<field name="view_id" ref="crm_case_inbound_phone_tree_view"/>
<field name="domain">[('state','=','done')]</field>
<field name="context" eval="'{\'search_default_section_id\':section_id, \'default_state\':\'done\', \'search_default_today\':1}'"/>
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
<field name="help">The Inbound Calls tool allows you to log your inbound calls on the fly. Each call you get will appear on the partner form to trace every contact you have with a partner. From the phone call form, you can trigger a request for another call, a meeting or an opportunity.</field>
<field name="help">This tool allows you to log your inbound calls on the fly. Each call you get will appear on the partner form to trace every contact you have with a partner. From the phone call form, you can trigger a request for another call, a meeting or an opportunity.</field>
</record>
@@ -90,24 +90,24 @@
<record model="ir.actions.act_window.view" id="action_crm_tag_form_phone_incoming0">
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_inbound_phone_form_view"/>
<field name="view_id" ref="crm_case_phone_form_view"/>
<field name="act_window_id" ref="crm_case_categ_phone_incoming0"/>
</record>
<menuitem name="Inbound" id="menu_crm_case_phone_inbound"
<menuitem name="Logged Calls" id="menu_crm_case_phone_inbound"
parent="crm.menu_crm_case_phone"
action="crm_case_categ_phone_incoming0" />
<record model="ir.actions.act_window" id="crm_case_categ_phone_outgoing0">
<field name="name">Outbound</field>
<field name="name">Scheduled Calls</field>
<field name="res_model">crm.phonecall</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar</field>
<field name="view_id" ref="crm_case_phone_tree_view"/>
<field name="domain" eval="'[(\'categ_id\',\'=\','+str(ref('categ_phone2'))+')]'"/>
<field name="context" eval="'{\'search_default_section_id\':section_id, \'default_state\':\'open\', \'search_default_current\':1, \'default_categ_id\': ' + str(ref('categ_phone2')) +'}'"/>
<field name="domain">[('state','!=','done')]</field>
<field name="context" eval="'{\'search_default_section_id\':section_id, \'default_state\':\'open\', \'search_default_current\':1,\'search_default_today\':1}'"/>
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
<field name="help">Outbound Calls list all the calls to be done by your sales team. A salesman can record the information about the call in the form view. This information will be stored in the partner form to trace every contact you have with a customer. You can also import a .CSV file with a list of calls to be done by your sales team.</field>
<field name="help">Scheduled calls list all the calls to be done by your sales team. A salesman can record the information about the call in the form view. This information will be stored in the partner form to trace every contact you have with a customer. You can also import a .CSV file with a list of calls to be done by your sales team.</field>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_phone_outgoing0">
@@ -131,7 +131,7 @@
<field name="act_window_id" ref="crm_case_categ_phone_outgoing0"/>
</record>
<menuitem name="Outbound" id="menu_crm_case_phone_outbound"
<menuitem name="Scheduled Calls" id="menu_crm_case_phone_outbound"
parent="crm.menu_crm_case_phone"
action="crm_case_categ_phone_outgoing0" />
+26 -95
View File
@@ -31,20 +31,20 @@
<field name="partner_contact"/>
<field name="partner_phone"/>
<field name="user_id"/>
<field name="categ_id" string="Type"/>
<field name="categ_id"/>
<field name="create_date" invisible="1"/>
<button string="Convert to Opportunity"
name="%(phonecall2opportunity_act)d"
states="draft,open,pending"
states="open,pending"
icon="gtk-index"
type="action" attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<button string="Meeting"
states="draft,open,pending" icon="gtk-redo"
states="open,pending" icon="gtk-redo"
name="action_make_meeting" type="object" />
<field name="state"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_close" string="Held" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
<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"/>
</tree>
</field>
@@ -61,21 +61,21 @@
<group colspan="6" col="7">
<field name="name" required="1"/>
<field name="partner_phone"/>
<field name="duration" widget="float_time" required="1"/>
<field name="duration" widget="float_time"/>
<button string="Schedule a Meeting" name="action_make_meeting" icon="gtk-redo" type="object"/>
<field name="date" required="1"/>
<field name="date"/>
<field name="user_id"/>
<field name="section_id" colspan="1" widget="selection" />
<button string="Convert to Opportunity"
name="%(phonecall2opportunity_act)d"
icon="gtk-index" type="action"
attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<label colspan="6" string=""/>
<button string="Schedule Other Call"
icon="terp-call-start"
name="%(phonecall_to_phonecall_act)d"
type="action" />
<label colspan="6" string=""/>
<button string="Convert to Opportunity"
name="%(phonecall2opportunity_act)d"
icon="gtk-index" type="action"
attrs="{'invisible':[('opportunity_id','!=',False)]}" />
</group>
@@ -98,8 +98,7 @@
<group col="2" colspan="2">
<separator colspan="2" string="Categorization" />
<field name="categ_id" widget="selection"
domain="[('object_id.model', '=', 'crm.phonecall')]"
string="Type" />
domain="[('object_id.model', '=', 'crm.phonecall')]"/>
<field name="priority"/>
<field name="opportunity_id"/>
</group>
@@ -109,94 +108,32 @@
<group col="8" colspan="4">
<field name="state" select="1" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
states="open,pending" type="object"
icon="gtk-cancel" />
<button name="case_open" string="Open"
states="draft,pending" type="object"
<button name="case_open" string="Todo"
states="pending" type="object"
icon="gtk-go-forward" />
<button name="case_pending" string="Not Held"
states="open" type="object" icon="gtk-media-pause" />
<button name="case_close" string="Held"
states="open,draft,pending" type="object"
states="open,pending" type="object"
icon="gtk-jump-to" />
<button name="case_reset" string="Reset to Draft"
states="done,cancel" type="object"
<button name="case_reset" string="Reset to Todo"
states="cancel" type="object"
icon="gtk-convert" />
</group>
</form>
</field>
</record>
<!--Inbound Phonecalls Form View -->
<record model="ir.ui.view" id="crm_case_inbound_phone_form_view">
<field name="name">CRM - Inbound Phone Call Form</field>
<field name="model">crm.phonecall</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Phone Call">
<group colspan="4" col="7">
<field name="name" required="1"/>
<field name="partner_phone"/>
<field name="duration" widget="float_time"/>
<button string="Schedule a Meeting"
name="action_make_meeting"
icon="gtk-redo"
type="object" />
<field name="date" required="1"/>
<field name="user_id"/>
<field name="section_id" colspan="1" widget="selection" />
<button string="Convert to Opportunity"
name="%(phonecall2opportunity_act)d"
icon="gtk-index" type="action"
attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<label colspan="6" string=""/>
<button string="Schedule Other Call"
icon="terp-call-start"
name="%(phonecall_to_phonecall_act)d"
type="action" />
</group>
<group col="3" colspan="2">
<separator colspan="3" string="Contacts" />
<field name="partner_id"
on_change="onchange_partner_id(partner_id, email_from)" />
<button string="Create a Partner"
icon="terp-partner"
name="%(action_crm_phonecall2partner)d"
type="action"
attrs="{'invisible':[('partner_id','!=',False)]}"
groups="base.group_partner_manager" />
<newline/>
<field name="partner_address_id"
on_change="onchange_partner_address_id(partner_address_id, email_from)" />
<newline/>
<field name="partner_mobile" />
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Categorization" />
<field name="categ_id" widget="selection"
domain="[('object_id.model', '=', 'crm.phonecall')]"
string="Type" />
<field name="priority"/>
<field name="opportunity_id"/>
</group>
<separator string="Description" colspan="4" />
<field name="description" nolabel="1" colspan="4" />
<separator colspan="4" />
</form>
</field>
</record>
<!--Inbound Phonecalls Tree View -->
<!--Logged Phonecalls Tree View -->
<record model="ir.ui.view" id="crm_case_inbound_phone_tree_view">
<field name="name">CRM - Inbound Phone Calls Tree</field>
<field name="name">CRM - Logged Phone Calls Tree</field>
<field name="model">crm.phonecall</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Phone Calls" colors="grey:state in ('cancel','done');blue:state in ('pending',)" editable="top">
<tree string="Phone Calls" editable="top">
<field name="date"/>
<field name="name"/>
<field name="partner_id"
@@ -207,21 +144,15 @@
<field name="partner_phone"/>
<field name="user_id"/>
<field name="categ_id" widget="selection"
domain="[('object_id.model', '=', 'crm.phonecall')]"
string="Type" />
domain="[('object_id.model', '=', 'crm.phonecall')]"/>
<field name="state" invisible="1"/>
<field name="create_date" invisible="1"/>
<button string="Schedule Other Call"
icon="terp-call-start"
name="%(phonecall_to_phonecall_act)d"
type="action" />
<button string="Convert to Opportunity"
name="%(phonecall2opportunity_act)d"
states="draft,open,pending"
icon="gtk-index"
type="action" attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<button string="Meeting"
states="draft,open,pending" icon="gtk-redo"
icon="gtk-redo"
name="action_make_meeting" type="object" />
</tree>
</field>
@@ -252,7 +183,7 @@
<search string="Search Phonecalls">
<filter icon="terp-check" string="Current"
name="current"
domain="[('state','in', ('draft','open','pending'))]"/>
domain="[('state','in', ('open','pending'))]"/>
<filter icon="terp-go-today" string="Today"
domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')),
('date','&gt;=',time.strftime('%%Y-%%m-%%d 00:00:00'))]"
+2 -2
View File
@@ -25,9 +25,9 @@ from crm import crm
AVAILABLE_STATES = [
('draft','Draft'),
('open','Open'),
('open','Todo'),
('cancel', 'Cancelled'),
('done', 'Closed'),
('done', 'Held'),
('pending','Pending')
]
@@ -108,7 +108,7 @@
<filter string="Partner" icon="terp-partner" context="{'group_by':'partner_id'}" />
<separator orientation="vertical" />
<filter string="Priority" icon="terp-rating-rated" domain="[]" context="{'group_by':'priority'}" />
<filter string="Type" icon="terp-stock_symbol-selection"
<filter string="Category" icon="terp-stock_symbol-selection"
domain="[]" context="{'group_by':'categ_id'}" />
<filter string="State" icon="terp-stock_effects-object-colorize"
domain="[]" context="{'group_by':'state'}" />
+2 -70
View File
@@ -54,82 +54,14 @@
<tree string="Phone Calls" colors="gray:state in ('draft', 'cancel','done','pending')">
<field name="date" string="Date"/>
<field name="name" string="Call Summary"/>
<field name="categ_id" string="Type" widget="selection"/>
<field name="categ_id" widget="selection"/>
<field name="user_id"/>
<field name="state"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_open" string="Todo" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_close" string="Held" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
<button name="case_pending" string="Not Held" states="open" type="object" icon="gtk-media-pause"/>
</tree>
<form string="Phone Call">
<group colspan="6" col="7">
<field name="name" required="1"/>
<field name="partner_phone" attrs="{'required': [('categ_id.name', '=', 'Outbound')]}"/>
<field name="duration" widget="float_time" required="1"/>
<button string="Schedule a Meeting" name="action_make_meeting" icon="gtk-redo" type="object"/>
<field name="date" required="1"/>
<field name="user_id"/>
<field name="section_id" colspan="1" widget="selection" />
<button string="Convert to Opportunity"
name="%(phonecall2opportunity_act)d"
icon="gtk-index" type="action"
attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<label colspan="6" string=""/>
<button string="Schedule Other Call"
icon="terp-call-start"
name="%(phonecall_to_phonecall_act)d"
type="action" />
</group>
<group col="3" colspan="2">
<separator colspan="3" string="Contacts" />
<field name="partner_id"
on_change="onchange_partner_id(partner_id, email_from)" />
<button string="Create a Partner"
icon="terp-partner"
name="%(action_crm_phonecall2partner)d"
type="action"
attrs="{'invisible':[('partner_id','!=',False)]}"
groups="base.group_partner_manager" />
<newline/>
<field name="partner_address_id"
on_change="onchange_partner_address_id(partner_address_id, email_from)" />
<newline/>
<field name="partner_mobile" />
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Categorization" />
<field name="categ_id" widget="selection"
domain="[('object_id.model', '=', 'crm.phonecall')]"
string="Type" />
<field name="priority"/>
<field name="opportunity_id"/>
</group>
<separator string="Description" colspan="4" />
<field name="description" nolabel="1" colspan="4" />
<separator colspan="4" />
<group col="8" colspan="4">
<field name="state" select="1" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_pending" string="Not Held"
states="open" type="object" icon="gtk-media-pause" />
<button name="case_close" string="Held"
states="open,draft,pending" type="object"
icon="gtk-jump-to" />
<button name="case_reset" string="Reset to Draft"
states="done,cancel" type="object"
icon="gtk-convert" />
</group>
</form>
</field>
</page>
</field>
@@ -67,6 +67,8 @@ class crm_merge_opportunity(osv.osv_memory):
ids = list(set(ids) - set(context.get('lead_ids', False)) )
lead_obj = self.pool.get('crm.lead')
op_id = lead_obj.search(cr, uid, [('id', 'in', ids)], order='create_date' , context=context)
if not op_id:
return False
opps = lead_obj.browse(cr, uid, [op_id[0]], context=context)
return opps[0]
@@ -22,6 +22,8 @@
from osv import osv, fields
from tools.translate import _
import time
class crm_opportunity2phonecall(osv.osv_memory):
"""Converts Opportunity to Phonecall"""
@@ -31,11 +33,13 @@ class crm_opportunity2phonecall(osv.osv_memory):
_columns = {
'name' : fields.char('Call summary', size=64, required=True, select=1),
'user_id' : fields.many2one('res.users', "Assign To"),
'date': fields.datetime('Date' , required=True),
'partner_id' : fields.many2one('res.partner', "Partner"),
'date': fields.datetime('Date'),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'categ_id': fields.many2one('crm.case.categ', 'Category', required=True, \
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="['|',('section_id','=',False),('section_id','=',section_id),\
('object_id.model', '=', 'crm.phonecall')]"),
('object_id.model', '=', 'crm.phonecall')]"),
'action': fields.selection([('schedule','Schedule a call'), ('log','Log a call')], 'Action', required=True),
}
def default_get(self, cr, uid, fields, context=None):
@@ -58,6 +62,7 @@ class crm_opportunity2phonecall(osv.osv_memory):
record_ids = context and context.get('active_ids', []) or []
res = super(crm_opportunity2phonecall, self).default_get(cr, uid, fields, context=context)
res.update({'action': 'schedule', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
for opp in opp_obj.browse(cr, uid, record_ids, context=context):
if 'name' in fields:
res.update({'name': opp.name})
@@ -67,6 +72,8 @@ class crm_opportunity2phonecall(osv.osv_memory):
res.update({'section_id': opp.section_id and opp.section_id.id or False})
if 'categ_id' in fields:
res.update({'categ_id': categ_id})
if 'partner_id' in fields:
res.update({'partner_id': opp.partner_id and opp.partner_id.id or False})
return res
def action_cancel(self, cr, uid, ids, context=None):
@@ -112,7 +119,7 @@ class crm_opportunity2phonecall(osv.osv_memory):
for this in self.browse(cr, uid, ids, context=context):
for opp in opp_obj.browse(cr, uid, record_ids, context=context):
new_case = phonecall_obj.create(cr, uid, {
vals = {
'name' : opp.name,
'case_id' : opp.id ,
'user_id' : this.user_id and this.user_id.id or False,
@@ -126,9 +133,12 @@ class crm_opportunity2phonecall(osv.osv_memory):
'partner_mobile' : opp.partner_address_id and opp.partner_address_id.mobile or False,
'priority': opp.priority,
'opportunity_id': opp.id
}, context=context)
phonecall_obj.case_open(cr, uid, [new_case])
}
new_case = phonecall_obj.create(cr, uid, vals, context=context)
if this.action == 'schedule':
phonecall_obj.case_open(cr, uid, [new_case])
elif this.action == 'log':
phonecall_obj.case_close(cr, uid, [new_case])
value = {
'name': _('Phone Call'),
@@ -9,19 +9,22 @@
<field name="model">crm.opportunity2phonecall</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Schedule a PhoneCall">
<separator string="Schedule a PhoneCall" colspan="4"/>
<form string="Schedule/Log a call">
<separator string="Schedule/Log a call" colspan="4"/>
<field name="action"/>
<separator string="Call Details" colspan="4"/>
<field name="name"/>
<field name="date" string="Planned Date"/>
<field name="date" string="Planned Date" attrs="{'invisible': [('action','=','log')]}"/>
<newline/>
<field name="user_id" />
<field name="partner_id" readonly="True"/>
<field name="user_id" />
<field name="section_id" widget="selection" />
<field name="categ_id" string="Type" widget="selection" domain="[('object_id.model', '=', 'crm.phonecall')]"/>
<separator string="" colspan="4"/>
<group colspan="4">
<label string ="" colspan="2"/>
<group colspan="4" col="3">
<button name="action_cancel" string="_Cancel" icon="gtk-cancel" special="cancel" />
<button name="action_apply" type="object" string="_Schedule Call" icon="gtk-ok" />
<button name="action_apply" type="object" string="Log call" icon="gtk-ok" attrs="{'invisible' : [('action', '!=', 'log')]}" />
<button name="action_apply" type="object" string="Schedule call" icon="gtk-ok" attrs="{'invisible' : [('action', '!=', 'schedule')]}" />
</group>
</form>
</field>
@@ -30,7 +33,7 @@
<!-- Opportunity to Phonecall action -->
<record model="ir.actions.act_window" id="opportunity2phonecall_act">
<field name="name">Schedule Call</field>
<field name="name">Schedule/Log Call</field>
<field name="res_model">crm.opportunity2phonecall</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
@@ -31,43 +31,14 @@ class crm_phonecall2opportunity(osv.osv_memory):
def action_cancel(self, cr, uid, ids, context=None):
"""
Closes Phonecall to Opportunity form
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Phonecall to Opportunity's IDs
@param context: A standard dictionary for contextual values
"""
return {'type':'ir.actions.act_window_close'}
def view_init(self, cr, uid, fields, context=None):
"""
This function checks for precondition before wizard executes
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param fields: List of fields for default value
@param context: A standard dictionary for contextual values
"""
phonecall_obj = self.pool.get('crm.phonecall')
record_id = context and context.get('active_id', False) or False
case = phonecall_obj.browse(cr, uid, record_id, context=context)
if case.state in ['done', 'cancel']:
raise osv.except_osv(_("Warning"), _("Closed/Cancelled Phone \
Call can not be converted into Opportunity"))
def action_apply(self, cr, uid, ids, context=None):
"""
This converts Phonecall to Opportunity and opens Phonecall view
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Phonecall to Opportunity IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for created Opportunity form
"""
record_id = context and context.get('active_id', False) or False
if record_id:
@@ -22,6 +22,8 @@
from osv import osv, fields
from tools.translate import _
import time
class crm_phonecall2phonecall(osv.osv_memory):
""" Converts Phonecall to Phonecall"""
@@ -84,6 +86,10 @@ class crm_phonecall2phonecall(osv.osv_memory):
'date': this.date
}
phonecall_id = phonecall_obj.create(cr, uid, values, context=context)
if this.action == 'schedule':
phonecall_obj.case_open(cr, uid, [phonecall_id])
elif this.action == 'log':
phonecall_obj.case_close(cr, uid, [phonecall_id])
res = {
'name': _('Phone Call'),
@@ -102,11 +108,13 @@ class crm_phonecall2phonecall(osv.osv_memory):
_columns = {
'name' : fields.char('Call summary', size=64, required=True, select=1),
'user_id' : fields.many2one('res.users',"Assign To"),
'categ_id': fields.many2one('crm.case.categ', 'Category', required=True, \
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="['|',('section_id','=',False),('section_id','=',section_id),\
('object_id.model', '=', 'crm.phonecall')]"),
'date': fields.datetime('Date', required=True),
'date': fields.datetime('Date'),
'section_id':fields.many2one('crm.case.section','Sales Team'),
'action': fields.selection([('schedule','Schedule a call'), ('log','Log a call')], 'Action', required=True),
'partner_id' : fields.many2one('res.partner', "Partner"),
}
def default_get(self, cr, uid, fields, context=None):
@@ -122,7 +130,7 @@ class crm_phonecall2phonecall(osv.osv_memory):
"""
res = super(crm_phonecall2phonecall, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False
res.update({'action': 'schedule', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
if record_id:
phonecall = self.pool.get('crm.phonecall').browse(cr, uid, record_id, context=context)
@@ -142,6 +150,8 @@ class crm_phonecall2phonecall(osv.osv_memory):
res.update({'section_id': phonecall.section_id and phonecall.section_id.id or False})
if 'categ_id' in fields:
res.update({'categ_id': categ_id})
if 'partner_id' in fields:
res.update({'partner_id': phonecall.partner_id and phonecall.partner_id.id or False})
return res
crm_phonecall2phonecall()
@@ -9,18 +9,21 @@
<field name="model">crm.phonecall2phonecall</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Schedule Other Call">
<separator string="Schedule Other Call" colspan="4"/>
<form string="Schedule/Log a call">
<separator string="Schedule/Log a call" colspan="4"/>
<field name="action"/>
<separator string="Call Details" colspan="4"/>
<field name="name"/>
<field name="date" string="Planned Date"/>
<field name="date" string="Planned Date" attrs="{'invisible': [('action','=','log')]}"/>
<field name="partner_id" readonly="True"/>
<field name="user_id" />
<field name="section_id"/>
<field name="categ_id" string="Type" widget="selection" domain="[('object_id.model', '=', 'crm.phonecall')]"/>
<separator string=" " colspan="4"/>
<group colspan="4" col="3" >
<label string=" " />
<button name="action_cancel" string="_Cancel" icon="gtk-cancel" special="cancel" />
<button name="action_apply" type="object" string="_Schedule" icon="gtk-go-forward" />
<button name="action_apply" type="object" string="Log call" icon="gtk-ok" attrs="{'invisible' : [('action', '!=', 'log')]}" />
<button name="action_apply" type="object" string="Schedule call" icon="gtk-ok" attrs="{'invisible' : [('action', '!=', 'schedule')]}" />
</group>
</form>
</field>