[Merge] Merge from trunk social bth branch to get all crm_case methods.
bzr revid: jra@tinyerp.com-20120315064645-mbkzin1jwbg25yol
This commit is contained in:
+18
-20
@@ -258,25 +258,19 @@ class crm_base(object):
|
||||
data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value'])
|
||||
return {'value': data}
|
||||
|
||||
def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None):
|
||||
def case_open_send_note(self, cr, uid, ids, context=None):
|
||||
return True
|
||||
|
||||
def _case_open_notification(self, case, context=None):
|
||||
def case_close_send_note(self, cr, uid, ids, context=None):
|
||||
return True
|
||||
|
||||
def _case_close_notification(self, case, context=None):
|
||||
def case_cancel_send_note(self, cr, uid, ids, context=None):
|
||||
return True
|
||||
|
||||
def _case_cancel_notification(self, case, context=None):
|
||||
def case_pending_send_note(self, cr, uid, ids, context=None):
|
||||
return True
|
||||
|
||||
def _case_pending_notification(self, case, context=None):
|
||||
return True
|
||||
|
||||
def _case_escalate_notification(self, case, context=None):
|
||||
return True
|
||||
|
||||
def _case_phonecall_notification(self, case, action, context=None):
|
||||
def case_reset_send_note(self, cr, uid, ids, context=None):
|
||||
return True
|
||||
|
||||
def case_open(self, cr, uid, ids, context=None):
|
||||
@@ -289,7 +283,7 @@ class crm_base(object):
|
||||
if not case.user_id:
|
||||
data['user_id'] = uid
|
||||
self.write(cr, uid, [case.id], data)
|
||||
self._case_open_notification(case, context=context)
|
||||
self.case_open_send_note(cr, uid, [case.id], context=context)
|
||||
self._action(cr, uid, cases, 'open')
|
||||
|
||||
return True
|
||||
@@ -302,7 +296,7 @@ class crm_base(object):
|
||||
cases[0].state # to fill the browse record cache
|
||||
self.write(cr, uid, ids, {'state': 'done', 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), })
|
||||
# We use the cache of cases to keep the old case state
|
||||
self._case_close_notification(cases, context=context)
|
||||
self.case_close_send_note(cr, uid, ids, context=context)
|
||||
self._action(cr, uid, cases, 'done')
|
||||
return True
|
||||
|
||||
@@ -314,7 +308,7 @@ class crm_base(object):
|
||||
cases[0].state # to fill the browse record cache
|
||||
self.write(cr, uid, ids, {'state': 'cancel', 'active': True})
|
||||
# We use the cache of cases to keep the old case state
|
||||
self._case_cancel_notification(cases, context=context)
|
||||
self.case_cancel_send_note(cr, uid, ids, context=context)
|
||||
self._action(cr, uid, cases, 'cancel')
|
||||
return True
|
||||
|
||||
@@ -325,7 +319,7 @@ class crm_base(object):
|
||||
cases = self.browse(cr, uid, ids)
|
||||
cases[0].state # to fill the browse record cache
|
||||
self.write(cr, uid, ids, {'state': 'pending', 'active': True})
|
||||
self._case_pending_notification(cases, context=context)
|
||||
self.case_pending_send_note(cr, uid, ids, context=context)
|
||||
self._action(cr, uid, cases, 'pending')
|
||||
return True
|
||||
|
||||
@@ -336,6 +330,7 @@ class crm_base(object):
|
||||
cases = self.browse(cr, uid, ids)
|
||||
cases[0].state # to fill the browse record cache
|
||||
self.write(cr, uid, ids, {'state': 'draft', 'active': True})
|
||||
self.case_reset_send_note(cr, uid, ids, context=context)
|
||||
self._action(cr, uid, cases, 'draft')
|
||||
return True
|
||||
|
||||
@@ -414,6 +409,9 @@ class crm_case(crm_base):
|
||||
default.update({ 'date_open': False })
|
||||
return super(crm_case, self).copy(cr, uid, id, default, context=context)
|
||||
|
||||
def case_escalate_send_note(self, cr, uid, ids, context=None):
|
||||
return True
|
||||
|
||||
def case_open(self, cr, uid, ids, context=None):
|
||||
"""Opens Case"""
|
||||
cases = self.browse(cr, uid, ids)
|
||||
@@ -422,7 +420,7 @@ class crm_case(crm_base):
|
||||
if not case.user_id:
|
||||
data['user_id'] = uid
|
||||
self.write(cr, uid, [case.id], data)
|
||||
self._case_open_notification(case, context=context)
|
||||
self.case_open_send_note(cr, uid, [case.id], context=context)
|
||||
self._action(cr, uid, cases, 'open')
|
||||
return True
|
||||
|
||||
@@ -436,7 +434,7 @@ class crm_case(crm_base):
|
||||
#
|
||||
# We use the cache of cases to keep the old case state
|
||||
#
|
||||
self._case_close_notification(cases, context=context)
|
||||
self.case_close_send_note(cr, uid, ids, context=context)
|
||||
self._action(cr, uid, cases, 'done')
|
||||
return True
|
||||
|
||||
@@ -454,7 +452,7 @@ class crm_case(crm_base):
|
||||
raise osv.except_osv(_('Error !'), _('You can not escalate, you are already at the top level regarding your sales-team category.'))
|
||||
self.write(cr, uid, [case.id], data)
|
||||
cases = self.browse(cr, uid, ids)
|
||||
self._case_escalate_notification(cases, context=context)
|
||||
self.case_escalate_send_note(cr, uid, ids, context=context)
|
||||
self._action(cr, uid, cases, 'escalate')
|
||||
return True
|
||||
|
||||
@@ -464,7 +462,7 @@ class crm_case(crm_base):
|
||||
cases[0].state # to fill the browse record cache
|
||||
self.write(cr, uid, ids, {'state': 'cancel',
|
||||
'active': True})
|
||||
self._case_cancel_notification(cases, context=context)
|
||||
self.case_cancel_send_note(cr, uid, ids, context=context)
|
||||
self._action(cr, uid, cases, 'cancel')
|
||||
return True
|
||||
|
||||
@@ -473,7 +471,7 @@ class crm_case(crm_base):
|
||||
cases = self.browse(cr, uid, ids)
|
||||
cases[0].state # to fill the browse record cache
|
||||
self.write(cr, uid, ids, {'state': 'pending', 'active': True})
|
||||
self._case_pending_notification(cases, context=context)
|
||||
self.case_pending_send_note(cr, uid, ids, context=context)
|
||||
self._action(cr, uid, cases, 'pending')
|
||||
return True
|
||||
|
||||
|
||||
+76
-79
@@ -226,7 +226,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(crm_lead, self).create(cr, uid, vals, context)
|
||||
self._case_create_notification(cr, uid, [obj_id], context=context)
|
||||
self.case_create_send_note(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
|
||||
@@ -271,78 +271,82 @@ class crm_lead(crm_case, osv.osv):
|
||||
def stage_find_won(self, cr, uid, section_id):
|
||||
return self.stage_find_percent(cr, uid, 100.0, section_id)
|
||||
|
||||
def _case_create_notification(self, cr, uid, ids, context=None):
|
||||
def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None):
|
||||
result = {}
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_subscribe(cr, uid, ids, [obj.user_id.id], context=context)
|
||||
if obj.type=="opportunity" and obj.state=="draft":
|
||||
message = _("Opportunity is <b>created</b>.")
|
||||
elif obj.type=="lead" :
|
||||
message = _("Lead is <b>created</b>.")
|
||||
else:
|
||||
message = _("The case has been <b>created</b>.")
|
||||
self.message_append_note(cr, uid, ids, _('System notification'),
|
||||
message, type='notification', need_action_user_id=obj.user_id.id, context=context)
|
||||
result[obj.id] = False
|
||||
if (obj.state == 'draft' and obj.user_id):
|
||||
result[obj.id] = obj.user_id.id
|
||||
return result
|
||||
|
||||
def case_reset_send_note(self, cr, uid, ids, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
message = _("%s has been <b>renewed</b>.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead')
|
||||
lead.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def _case_open_notification(self, lead, context=None):
|
||||
if lead.state != 'draft' and lead.state != 'pending':
|
||||
return False
|
||||
if lead.type == 'lead':
|
||||
message = _("The lead has been <b>opened</b>.")
|
||||
elif lead.type == 'opportunity':
|
||||
message = _("The opportunity has been <b>opened</b>.")
|
||||
else:
|
||||
message = _("The case has been <b>opened</b>.")
|
||||
lead.message_append_note('' ,message, need_action_user_id=lead.user_id.id)
|
||||
def case_create_send_note(self, cr, uid, ids, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
self.message_subscribe(cr, uid, ids, [lead.user_id.id], context=context)
|
||||
message = _("%s has been <b>created</b>.") % ('Opportunity' if lead.type == 'opportunity' and lead.state == 'draft' else 'Lead')
|
||||
self.message_append_note(cr, uid, ids, _('System notification'),
|
||||
message, type='notification', context=context)
|
||||
return True
|
||||
|
||||
def _case_close_notification(self, lead, context=None):
|
||||
lead[0].message_mark_done(context)
|
||||
if lead[0].type == 'lead':
|
||||
message = _("The lead has been <b>closed</b>.")
|
||||
elif lead[0].type == 'opportunity':
|
||||
message = _("The opportunity has been <b>closed</b>.")
|
||||
else:
|
||||
message = _("The case has been <b>closed</b>.")
|
||||
lead[0].message_append_note('' ,message)
|
||||
def case_open_send_note(self, cr, uid, ids, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
if lead.state == 'draft' and lead.state == 'pending':
|
||||
return False
|
||||
message = _("%s has been <b>opened</b>.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead')
|
||||
lead.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def _case_mark_lost_notification(self, lead, context=None):
|
||||
lead.message_mark_done(context)
|
||||
message = _("The opportunity has been <b>marked as lost</b>.")
|
||||
lead.message_append_note('' ,message)
|
||||
def case_close_send_note(self, cr, uid, ids, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
message = _("%s has been <b>closed</b>.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead')
|
||||
lead.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def _case_mark_won_notification(self, lead, context=None):
|
||||
lead.message_mark_done(context)
|
||||
message = _("The opportunity has been <b>won</b>.")
|
||||
lead.message_append_note('' ,message)
|
||||
def case_mark_lost_send_note(self, cr, uid, ids, context=None):
|
||||
for opportunity in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Opportunity has been <b>marked as lost</b>.")
|
||||
opportunity.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def _case_cancel_notification(self, lead, context=None):
|
||||
lead[0].message_mark_done(context)
|
||||
if lead[0].type == 'lead':
|
||||
message = _("The lead has been <b>cancelled</b>.")
|
||||
elif lead[0].type == 'opportunity':
|
||||
message = _("The opportunity has been <b>cancelled</b>.")
|
||||
lead[0].message_append_note('' ,message)
|
||||
def case_mark_won_send_note(self, cr, uid, ids, context=None):
|
||||
for opportunity in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Opportunity has been <b>won</b>.")
|
||||
opportunity.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def _case_pending_notification(self, case, context=None):
|
||||
if case[0].type == 'lead':
|
||||
message = _("The lead is <b>pending</b>.")
|
||||
elif case[0].type == 'opportunity':
|
||||
message = _("The opportunity is <b>pending</b>.")
|
||||
case[0].message_append_note('' ,message)
|
||||
def case_cancel_send_note(self, cr, uid, ids, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
message = _("%s has been <b>cancelled</b>.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead')
|
||||
lead.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def _case_escalate_notification(self, case, context=None):
|
||||
message = _("The lead is <b>escalated</b>.")
|
||||
case.message_append_note('' ,message)
|
||||
def case_pending_send_note(self, cr, uid, ids, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
message = _("%s is <b>pending</b>.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead')
|
||||
lead.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def _case_phonecall_notification(self, cr, uid, ids, case, phonecall, action, context=None):
|
||||
def case_escalate_send_note(self, cr, uid, ids, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Lead has been <b>escalated</b>.")
|
||||
lead.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def case_phonecall_send_note(self, cr, uid, ids, case, phonecall, action, context=None):
|
||||
for obj in phonecall.browse(cr, uid, ids, context=context):
|
||||
if action == "schedule" :
|
||||
message = _("<b>%s a call</b> for the %s.") % (action, obj.date)
|
||||
else :
|
||||
message = _("<b>%s a call</b>.") % (action)
|
||||
message = _("<b>%s a call</b> for the <em>%s</em>.") % (action, obj.date)
|
||||
case.message_append_note('', message)
|
||||
if action == "schedule" :
|
||||
phonecall.message_append_note(cr, uid, ids, '', message, need_action_user_id=obj.user_id.id)
|
||||
|
||||
def case_partner_send_note(self, cr, uid, ids, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Partner has been <b>created</b>")
|
||||
lead.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def case_open(self, cr, uid, ids, context=None):
|
||||
res = super(crm_lead, self).case_open(cr, uid, ids, context)
|
||||
@@ -372,6 +376,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
"""
|
||||
res = super(crm_lead, self).case_reset(cr, uid, ids, context)
|
||||
self.write(cr, uid, ids, {'stage_id': False, 'probability': 0.0})
|
||||
self.case_reset_send_note(cr, uid, ids, context=context)
|
||||
return res
|
||||
|
||||
def case_mark_lost(self, cr, uid, ids, context=None):
|
||||
@@ -394,7 +399,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
stage_id = self.stage_find_won(cr, uid, lead.section_id.id or False)
|
||||
if stage_id:
|
||||
self.stage_set(cr, uid, [lead.id], stage_id)
|
||||
self._case_mark_won_notification(lead, context=context)
|
||||
self.case_mark_won_send_note(cr, uid, [lead.id], context=context)
|
||||
return res
|
||||
|
||||
def set_priority(self, cr, uid, ids, priority):
|
||||
@@ -500,7 +505,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
|
||||
subject = subject[0] + ", ".join(subject[1:])
|
||||
details = "\n\n".join(details)
|
||||
return opportunity.message_append_note(subject, body=details, need_action_user_id=opportunity.user_id.id)
|
||||
return opportunity.message_append_note(subject, body=details)
|
||||
|
||||
def _merge_opportunity_history(self, cr, uid, opportunity_id, opportunities, context=None):
|
||||
message = self.pool.get('mail.message')
|
||||
@@ -609,9 +614,9 @@ class crm_lead(crm_case, osv.osv):
|
||||
'partner_address_id': contact_id,
|
||||
}
|
||||
|
||||
def _convert_opportunity_notification(self, cr, uid, lead, context=None):
|
||||
success_message = _("Lead is <b>converted to an opportunity</b>.")
|
||||
lead.message_append_note(success_message ,success_message, need_action_user_id=lead.user_id.id)
|
||||
def convert_opportunity_send_note(self, cr, uid, lead, context=None):
|
||||
message = _("Lead has been <b>converted to an opportunity</b>.")
|
||||
lead.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def convert_opportunity(self, cr, uid, ids, partner_id, user_ids=False, section_id=False, context=None):
|
||||
@@ -629,7 +634,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
vals = self._convert_opportunity_data(cr, uid, lead, customer, section_id, context=context)
|
||||
self.write(cr, uid, [lead.id], vals, context=context)
|
||||
|
||||
self._convert_opportunity_notification(cr, uid, lead, context=context)
|
||||
self.convert_opportunity_send_note(cr, uid, lead, context=context)
|
||||
#TOCHECK: why need to change partner details in all messages of lead ?
|
||||
if lead.partner_id:
|
||||
msg_ids = [ x.id for x in lead.message_ids]
|
||||
@@ -656,7 +661,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
res_partner.write(cr, uid, partner_id, {'section_id': lead.section_id.id or False})
|
||||
contact_id = res_partner.address_get(cr, uid, [partner_id])['default']
|
||||
res = lead.write({'partner_id' : partner_id, 'partner_address_id': contact_id}, context=context)
|
||||
|
||||
self.case_partner_send_note(cr, uid, [lead.id], context)
|
||||
return res
|
||||
|
||||
def _lead_create_partner_address(self, cr, uid, lead, partner_id, context=None):
|
||||
@@ -757,13 +762,12 @@ class crm_lead(crm_case, osv.osv):
|
||||
'partner_mobile' : lead.partner_address_id and lead.partner_address_id.mobile or False,
|
||||
'priority': lead.priority,
|
||||
}
|
||||
|
||||
new_id = phonecall.create(cr, uid, vals, context=context)
|
||||
phonecall.case_open(cr, uid, [new_id])
|
||||
if action == 'log':
|
||||
phonecall.case_close(cr, uid, [new_id])
|
||||
phonecall_dict[lead.id] = new_id
|
||||
self._case_phonecall_notification(cr, uid, [new_id], lead, phonecall, action, context=context)
|
||||
self.case_phonecall_send_note(cr, uid, [new_id], lead, phonecall, action, context=context)
|
||||
return phonecall_dict
|
||||
|
||||
|
||||
@@ -905,16 +909,9 @@ class crm_lead(crm_case, osv.osv):
|
||||
# change probability of lead(s) if required by stage
|
||||
if not vals.get('probability') and stage.on_change:
|
||||
vals['probability'] = stage.probability
|
||||
text = _("Changed Stage to: %s") % stage.name
|
||||
|
||||
for case in self.browse(cr, uid, ids, context=context):
|
||||
if case.type == 'lead' or context.get('stage_type') == 'lead':
|
||||
message = _("The stage of lead has been changed to <b>%s</b>.") % (stage.name)
|
||||
case.message_append_note(text, message)
|
||||
elif case.type == 'opportunity':
|
||||
message = _("The stage of opportunity has been changed to <b>%s</b>.") % (stage.name)
|
||||
case.message_append_note(text, message)
|
||||
|
||||
message = _("Stage changed to <b>%s</b>.") % (stage.name)
|
||||
case.message_append_note('', message)
|
||||
return super(crm_lead,self).write(cr, uid, ids, vals, context)
|
||||
|
||||
crm_lead()
|
||||
|
||||
@@ -77,9 +77,10 @@
|
||||
icon="gtk-go-forward" context="{'stage_type': 'lead'}" />
|
||||
</group>
|
||||
<field name="type" invisible="1"/>
|
||||
<label colspan="6" string=""/>
|
||||
<button string="Send New Email"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Lead">
|
||||
@@ -168,7 +169,7 @@
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="message_ids_social" widget="ThreadView"/>
|
||||
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -434,15 +435,15 @@
|
||||
<button name="action_makeMeeting" type="object"
|
||||
string="Schedule Meeting" icon="gtk-redo" />
|
||||
<newline/>
|
||||
<button string="Send New Email"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
<newline/>
|
||||
<field name="date_action"/>
|
||||
<field name="title_action"/>
|
||||
<field name="priority" string="Priority"/>
|
||||
<newline/>
|
||||
<field name="type" invisible="1"/>
|
||||
<label colspan="6" string=""/>
|
||||
<button string="Send New Email"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Opportunity">
|
||||
@@ -537,7 +538,7 @@
|
||||
<field name="ref2"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="message_ids_social" widget="ThreadView"/>
|
||||
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
+51
-14
@@ -42,7 +42,7 @@ class crm_meeting(crm_base, osv.osv):
|
||||
_name = 'crm.meeting'
|
||||
_description = "Meeting"
|
||||
_order = "id desc"
|
||||
_inherit = "calendar.event"
|
||||
_inherit = ["calendar.event","mail.thread"]
|
||||
_columns = {
|
||||
# From crm.case
|
||||
'name': fields.char('Summary', size=124, required=True, states={'done': [('readonly', True)]}),
|
||||
@@ -82,20 +82,59 @@ class crm_meeting(crm_base, osv.osv):
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(crm_meeting, self).create(cr, uid, vals, context=context)
|
||||
self._case_opportunity_meeting_notification(cr, uid, [obj_id], context=context)
|
||||
self.case_create_send_note(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None):
|
||||
lead_obj = self.pool.get('crm.lead')
|
||||
|
||||
def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None):
|
||||
result = {}
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
if(obj.opportunity_id.id):
|
||||
newid = obj.opportunity_id.id
|
||||
message = _("<b>scheduled for meeting</b> %s.") % (obj.date)
|
||||
for lead in lead_obj.browse(cr, uid, [newid], context=context):
|
||||
lead.message_append_note('', message)
|
||||
result[obj.id] = False
|
||||
if (obj.state == 'draft' and obj.user_id):
|
||||
result[obj.id] = obj.user_id.id
|
||||
return result
|
||||
|
||||
def case_open(self, cr, uid, ids, *args):
|
||||
def case_create_send_note(self, cr, uid, ids, context=None):
|
||||
lead_obj = self.pool.get('crm.lead')
|
||||
phonecall_obj = self.pool.get('crm.phonecall')
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
message = _("The meeting has been <b>scheduled</b> on <em>%s</em>.") % (obj.date)
|
||||
if(obj.opportunity_id.id): # meeting can be create from phonecalls or opportunities, therefore checking for the parent
|
||||
newid = obj.opportunity_id.id
|
||||
for lead in lead_obj.browse(cr, uid, [newid], context=context):
|
||||
opp_message = _("Meeting linked to the opportunity <em>%s</em> has been <b>created and scheduled</b> on <em>%s</em>.") % (lead.name,obj.date)
|
||||
lead.message_append_note('', message)
|
||||
obj.message_append_note('', opp_message)
|
||||
elif(obj.phonecall_id.id):
|
||||
newid = obj.phonecall_id.id
|
||||
for phonecall in phonecall_obj.browse(cr, uid, [newid], context=context):
|
||||
phn_message = _("Meeting linked to the phonecall <em>%s</em> has been <b>created and scheduled</b> on <em>%s</em>.") % (phonecall.name,obj.date)
|
||||
phonecall.message_append_note('', message)
|
||||
obj.message_append_note('', phn_message)
|
||||
else:
|
||||
message = _("Meeting has been <b>scheduled</b> on <em>%s</em>.") % (obj.date)
|
||||
obj.message_append_note('', message)
|
||||
|
||||
def case_close_send_note(self, cr, uid, ids, context=None):
|
||||
for meeting in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Meeting has been <b>done</b>.")
|
||||
meeting.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def case_reset_send_note(self, cr, uid, ids, context=None):
|
||||
for meeting in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Meeting has been <b>renewed</b>.")
|
||||
meeting.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def case_open_send_note(self, cr, uid, ids, context=None):
|
||||
for meeting in self.browse(cr, uid, ids, context=context):
|
||||
if meeting.state != 'draft':
|
||||
return False
|
||||
message = _("Meeting has been <b>confirmed</b>.")
|
||||
meeting.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def case_open(self, cr, uid, ids, context=None):
|
||||
"""Confirms meeting
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@@ -103,11 +142,9 @@ class crm_meeting(crm_base, osv.osv):
|
||||
@param ids: List of Meeting Ids
|
||||
@param *args: Tuple Value for additional Params
|
||||
"""
|
||||
res = super(crm_meeting, self).case_open(cr, uid, ids, args)
|
||||
res = super(crm_meeting, self).case_open(cr, uid, ids, context)
|
||||
for (id, name) in self.name_get(cr, uid, ids):
|
||||
message = _("The meeting '%s' has been confirmed.") % name
|
||||
id=base_calendar.base_calendar_id2real_id(id)
|
||||
self.log(cr, uid, id, message)
|
||||
return res
|
||||
|
||||
crm_meeting()
|
||||
|
||||
@@ -216,6 +216,7 @@
|
||||
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
+62
-13
@@ -78,10 +78,6 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(crm_phonecall, self).create(cr, uid, vals, context=context)
|
||||
return obj_id
|
||||
|
||||
def _get_default_state(self, cr, uid, context=None):
|
||||
if context and context.get('default_state', False):
|
||||
return context.get('default_state')
|
||||
@@ -95,6 +91,58 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
'active': 1,
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(crm_phonecall, self).create(cr, uid, vals, context)
|
||||
for phonecall in self.browse(cr, uid, [obj_id], context=context):
|
||||
if not phonecall.opportunity_id:
|
||||
self.case_open_send_note(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None):
|
||||
result = {}
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
result[obj.id] = False
|
||||
if (obj.state == 'draft' and obj.user_id):
|
||||
result[obj.id] = obj.user_id.id
|
||||
return result
|
||||
|
||||
def case_cancel_send_note(self, cr, uid, ids, context=None):
|
||||
for phonecall in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Phonecall has been <b>cancelled</b>.")
|
||||
phonecall.message_append_note( _('System notification'),
|
||||
message, type='notification', context=context)
|
||||
return True
|
||||
|
||||
def case_pending_send_note(self, cr, uid, ids, context=None):
|
||||
for phonecall in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Phonecall is <b>pending</b>.")
|
||||
phonecall.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def case_done_send_note(self, cr, uid, ids, context=None):
|
||||
for phonecall in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Phonecall has been <b>done</b>.")
|
||||
phonecall.message_append_note('', message)
|
||||
return True
|
||||
|
||||
def case_open_send_note(self, cr, uid, ids, context=None):
|
||||
lead_obj = self.pool.get('crm.lead')
|
||||
for phonecall in self.browse(cr, uid, ids, context=context):
|
||||
phonecall.message_subscribe([phonecall.user_id.id], context=context)
|
||||
if phonecall.opportunity_id :
|
||||
for lead in lead_obj.browse(cr, uid, [phonecall.opportunity_id.id], context=context):
|
||||
message = _("Phonecall linked to the opportunity <em>%s</em> has been <b>created and opened </b>on <em>%s</em>.") % (lead.name, phonecall.date)
|
||||
else:
|
||||
message = _("Phonecall has been <b>created and opened</b>.")
|
||||
phonecall.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
def case_partner_send_note(self, cr, uid, ids, context=None):
|
||||
for phonecall in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Partner has been <b>created</b>")
|
||||
phonecall.message_append_note('' ,message)
|
||||
return True
|
||||
|
||||
# From crm.case
|
||||
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
|
||||
res = super(crm_phonecall, self).onchange_partner_address_id(cr, uid, ids, add, email)
|
||||
@@ -105,7 +153,7 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
res['value']['partner_mobile'] = address.mobile
|
||||
return res
|
||||
|
||||
def case_close(self, cr, uid, ids, *args):
|
||||
def case_close(self, cr, uid, ids, context=None):
|
||||
"""Overrides close for crm_case for setting close date
|
||||
"""
|
||||
res = True
|
||||
@@ -115,22 +163,24 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
if phone.duration <=0:
|
||||
duration = datetime.now() - datetime.strptime(phone.date, '%Y-%m-%d %H:%M:%S')
|
||||
data.update({'duration': duration.seconds/float(60)})
|
||||
res = super(crm_phonecall, self).case_close(cr, uid, [phone_id], args)
|
||||
res = super(crm_phonecall, self).case_close(cr, uid, [phone_id], context)
|
||||
self.write(cr, uid, [phone_id], data)
|
||||
self.case_done_send_note(cr, uid, [phone_id], context);
|
||||
return res
|
||||
|
||||
def case_reset(self, cr, uid, ids, *args):
|
||||
def case_reset(self, cr, uid, ids, context=None):
|
||||
"""Resets case as Todo
|
||||
"""
|
||||
res = super(crm_phonecall, self).case_reset(cr, uid, ids, args)
|
||||
res = super(crm_phonecall, self).case_reset(cr, uid, ids, context)
|
||||
self.write(cr, uid, ids, {'duration': 0.0, 'state':'open'})
|
||||
self.case_open_send_note(cr, uid, ids, context=context)
|
||||
return res
|
||||
|
||||
|
||||
def case_open(self, cr, uid, ids, *args):
|
||||
def case_open(self, cr, uid, ids, context=None):
|
||||
"""Overrides cancel for crm_case for setting Open Date
|
||||
"""
|
||||
res = super(crm_phonecall, self).case_open(cr, uid, ids, *args)
|
||||
res = super(crm_phonecall, self).case_open(cr, uid, ids, context)
|
||||
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
|
||||
return res
|
||||
|
||||
@@ -163,9 +213,7 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
'partner_mobile' : call.partner_mobile,
|
||||
'priority': call.priority,
|
||||
}
|
||||
|
||||
new_id = self.create(cr, uid, vals, context=context)
|
||||
self.case_open(cr, uid, [new_id])
|
||||
if action == 'log':
|
||||
self.case_close(cr, uid, [new_id])
|
||||
phonecall_dict[call.id] = new_id
|
||||
@@ -182,7 +230,8 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
return partner_id
|
||||
|
||||
def _call_set_partner(self, cr, uid, ids, partner_id, context=None):
|
||||
return self.write(cr, uid, ids, {'partner_id' : partner_id}, context=context)
|
||||
self.write(cr, uid, ids, {'partner_id' : partner_id}, context=context)
|
||||
self.case_partner_send_note(cr, uid, ids, context)
|
||||
|
||||
def _call_create_partner_address(self, cr, uid, phonecall, partner_id, context=None):
|
||||
address = self.pool.get('res.partner.address')
|
||||
|
||||
@@ -123,6 +123,7 @@
|
||||
states="cancel" type="object"
|
||||
icon="gtk-convert" />
|
||||
</group>
|
||||
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
<menuitem id="mail_debug_msgs" name="Messages" parent="mail_debug" action="action_view_all_messages_short"/>
|
||||
<menuitem id="mail_debug_subs" name="Subscriptions" parent="mail_debug" action="action_view_subscriptions"/>
|
||||
<menuitem id="mail_debug_notifs" name="Pushed notif" parent="mail_debug" action="action_view_notifications"/>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -106,8 +106,8 @@ class crm_make_sale(osv.osv_memory):
|
||||
sale_order = sale_obj.browse(cr, uid, new_id, context=context)
|
||||
case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id})
|
||||
new_ids.append(new_id)
|
||||
message = _("Opportunity %s is converted to Quotation %s.") % (case.name, sale_order.name)
|
||||
case.message_append_note( _("Converted to Sales Quotation(%s).") % (sale_order.name),message,need_action_user_id=sale_order.user_id.id)
|
||||
message = _("Opportunity has been <b>converted to Quotation</b> <em>%s</em>.") % (sale_order.name)
|
||||
case.message_append_note('', message)
|
||||
|
||||
if make.close:
|
||||
case_obj.case_close(cr, uid, data)
|
||||
|
||||
Reference in New Issue
Block a user